Reputation: 8589
I am trying to get the current location using this code in my viewDidLoad method:
//init the location manager
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
and I have my delegate methods:
//if it fails to get the location
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
self.currentLocation = newLocation;
}
my UIViewController conforms to the CLLocationManagerDelegate however I am getting no activity, no NSLog or errors. I have tested on a device. Could someone give me a pointer to what might be going wrong here please?
Upvotes: 0
Views: 182
Reputation: 4641
make sure, you follow the guidelines in the Documentation
especially that the ´UIRequiredDeviceCapabilities´ key is in your Info.plist.
Upvotes: 1