Have a simple app that gets gps location
. I would like to get a gps location before the app initialises. It seems for me that GPS location is updated asynchronously and I do get the app screen on the background loading while the question pops up: "allow appliction to use your current location?"
Well, how can I make a callback (sorry, coming from Ruby / JS background) to wait until I get the current location.
The code:
- (void)viewWillAppear:(BOOL)animated { // Set the main view to utilize the entire application frame space of the device. // Change this to suit your view's UI footprint needs in your application. CLController = [[CoreLocationController alloc] init]; CLController.delegate = self; [CLController.locMgr startUpdatingLocation]; self.view.frame = [[UIScreen mainScreen] applicationFrame]; [super viewWillAppear:animated]; }
in CoreLocationController.m
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"Update location"); if([self.delegate conformsToProtocol:@protocol(CoreLocationControllerDelegate)]) { [self.delegate locationUpdate:newLocation]; [self.locMgr stopUpdatingLocation]; # => wait initialisation until this point and than continue