1

I'm working on a simple app that will find a person's coordinates and altitude every second and it will display it on the screen. Finding coordinates was simple, but I scoured the internet and everything about altitude was so complex and required many different functions.

This is what I have so far. I'm using a "single view" format.

CLLocationManager *locationManager;

- (NSString *)deviceLocation {
    return [NSString stringWithFormat:@"latitude: %f longitude: %f",         locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude];
}

- (void)viewDidLoad
{
    locationManager = [[CLLocationManager alloc] init];
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
    locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
    [locationManager startUpdatingLocation];
    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timer) userInfo:nil repeats:YES];

    [super viewDidLoad];
}

-(void)timer
{
    NSLog(@"%@", [self deviceLocation]);
    coordinates.text = [self deviceLocation];
    altitude.text = ;\\altitude goes here

}
Jacob Richman
  • 471
  • 1
  • 5
  • 8
  • Doesn't `locationManager.location.altitude` give you the altitude? Note that instead of a timer, it would be better to use the CLLocationManager's delegate method didUpdateLocations. Set locationManager.delegate to self and implement the delegate method. –  Aug 31 '14 at 12:55

0 Answers0