in ios 8+ u need to request permission [self.locationManager requestWhenInUseAuthorization]
for only us3 when in app and [self.locationManager requestAlwaysAuthorization]
for always use location
this code perfectly work on ios 8
#pragma mark -
#pragma mark CLLocationManagerDelegate
- (void)startSignificantChangeUpdates
{
if ([CLLocationManager locationServicesEnabled])
{
if (!self.locationManager)
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
// request location when app in use
[self.locationManager requestWhenInUseAuthorization];
[self.locationManager startUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
[self.locationManager stopUpdatingLocation];
CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
[geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
for (CLPlacemark * placemark in placemarks) {
NSString *country = placemark.ISOcountryCode;
cityName = [placemark locality];
}
}];
}