Basically half the time the delegate method
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations;
is not called at all. But the other half of the time it works perfectly! I've found that it usually happens when I first start up Xcode after closing and quitting it, but then after that or a couple runs after that it seems to work fine. I'm not 100% sure if it's just an Xcode problem or what, I'll be getting a developer's license soon so I'll see if it will work fine on an actual device.
Starting from the viewDidAppear (tried in viewDidLoad also, made no difference), I run a method to init my locationManager stuff:
locationManager = [[CLLocationManager alloc]init];
[locationManager setDelegate:self];
locationManager.distanceFilter = 20.0f;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.pausesLocationUpdatesAutomatically = NO;
if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
[locationManager requestAlwaysAuthorization];
[locationManager startUpdatingLocation];
Sometimes this works, sometimes it doesn't. I even made a timer to re-run this every so-and-so seconds, and this doesn't work.
Is there something else I should do? Is there any answer to this problem?
Thanks.
didUpdateLocations
is called when the OS has location updates to deliver. Sometimes it does, other times (less often) it doesn't. – MurkNSLocationAlwaysUsageDescription
added to your apps info.plist file? Two have you set a location in the simulator? (Debug->Location) – Roanna