Furthermore in iOS8 you must have two extra things:
-
Add a key to your
Info.plist
and request authorization from the location manager asking it to start.-
NSLocationWhenInUseUsageDescription
-
NSLocationAlwaysUsageDescription
-
-
You need to request authorization for the corresponding location method.
-
[self.locationManager requestWhenInUseAuthorization]
-
[self.locationManager requestAlwaysAuthorization]
-
Code example:
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
// Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
Source: http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/