Hello,
I am trying to make a test app to get the latitude of my current location, but I can't get it to work
Here is my code:
The lattitudeLabel is an IBOutlet. I don't get any errors or warnings, the problem is my lattitueLabel's value is 0 and I am pretty sure my lattitude isn't 0. (I live in the US
)
I get the NSAlert asking me to turn on location services and I do, but my label's value doesn't change after I click yes.
Thanks!
I am trying to make a test app to get the latitude of my current location, but I can't get it to work
Here is my code:
Code:
-(void)awakeFromNib{
if ([CLLocationManager locationServicesEnabled] == TRUE) {
NSLog(@"Location Services are online");
} else {
NSLog(@"Location services are disabled");
}
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
NSString *lattitude = [[NSString alloc]initWithFormat:@"%g",location.coordinate.latitude];
[lattitudeLabel setStringValue:lattitude];
[locationManager stopUpdatingLocation];
}
The lattitudeLabel is an IBOutlet. I don't get any errors or warnings, the problem is my lattitueLabel's value is 0 and I am pretty sure my lattitude isn't 0. (I live in the US
I get the NSAlert asking me to turn on location services and I do, but my label's value doesn't change after I click yes.
Thanks!