I\'m trying to use the CLLocationManager
framework in my iOS project to access the user\'s location but when I call
[locationManager startUpdat
I think you should check this link.You are not retaining the location manager object when declaring.
please give property to you object @property(nonatomic, strong)
Why the CLLocationManager delegate is not getting called in iPhone SDK 4.0?
I had the following in my code base:
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
if( status == kCLAuthorizationStatusAuthorizedAlways ) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.distanceFilter = 200;
}
}
Turns out that this was getting called in an infinite loop, because initializing a locationManager triggers this method for some reason? I had not realized that. I had put it there to catch when permissions were granted. Instead, I set up a location manager and started updating the location, but then this fired and replaced it with one that wasn't updating the location, and kept looping over and over.
Solution for me was just to add && !_locationManager
to the if condition.