title: Getting Altitude(height from sea level) of my location in iphone SDK
body: <p>I am trying to get Altitude of my location in my application. But every time I try <code>altitude</code> property of <code>CLLocation</code> object I am getting <code>0.00</code> as result. </p>
  
  <p>I googled for my query and I got a similar question <a href="https://stackoverflow.com/questions/4870480/ios-corelocation-altitude">here</a> and <a href="https://stackoverflow.com/questions/5788328/altitude-problem-ios">here</a>. This link is saying that if I access CLLocation with wifi or cell tower it will be null. Even if I try to set <code>desireAccuracy</code> to best than even it don't make sure that app will use GPS. It is also saying that if I am indoor that I won't be able to access GPS.</p>
  
  <p>I many cases it its not sure that app will use GPS only. I want some way for getting Altitude from wifi or cell tower too. For that I googled more and I got <a href="https://developers.google.com/earth/documentation/ocean" rel="nofollow noreferrer">Google Earth API</a> but I think this is for Microsoft .net technology only.</p>
  
  <p>Now according to this situation I think for a solution I can create a web service in Microsoft Technology and pass my location there and I can get altitude as response but I don't want to do this.</p>
  
  <p>Can anyone suggest me how to get my location's altitude from ios. Is there any way available or not? If yes than please navigate me in right direction.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Edit1</strong> </p>
  
  <p>I used <code>CLLocationManager</code> for updating location and when I get my location I need altitude.</p>
  
  <p><strong>Edit2</strong></p>
  
  <p>According to @fishinear's answer I tried following code:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      manager = [[CLLocationManager alloc] init];
      [manager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation];
      [manager setDistanceFilter:kCLDistanceFilterNone];
      [manager setDelegate:self];
      [manager startUpdatingLocation];
  // Do any additional setup after loading the view, typically from a nib.
  }
  
  - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
      if ([newLocation verticalAccuracy] &gt;= 0) {
          NSLog(@"Altitude = %lf",newLocation.altitude);
      }
      NSLog(@"Vertical Accuracy : %lf",newLocation.verticalAccuracy);
  }
  </code></pre>
  
  <p><code>verticalAccuracy</code> is always <code>-1</code>. It is not changing even after running the app to last 30 Mins. I am runnin ios 4.3.2 on my 3GS. I am indoor so I think it is not accessing GPS using this code even.</p>