All,
I have this code :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)];
self.locationmanager = [CLLocationManager new];
[self.locationmanager setDesiredAccuracy:kCLLocationAccuracyBest];
[self.locationmanager setDistanceFilter:kCLDistanceFilterNone];
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusRestricted || status == kCLAuthorizationStatusDenied)
{
// location not avaialble create an alert.
NSLog(@"User has not allowed location to be tracked");
}
if (status == kCLAuthorizationStatusAuthorized)
{
in the AppDelegate didfinishLauncingWithOptions, and I need to it to check / allow the location lat/long to be retrieved, the ViewdidLoad opens before the IF statement to see if it authorised. So the ViewDidLoad doesn't get the correct information. When the if(authorised) is executed then it goes to a db with the lat and long and then the view did load should get the data. but the view did load is blank as the if statement has not be ran. Within the IF statement it executes a block (NFNetworking) and it does get there. If i re-run it from XCODE it does.
See Question&Answers more detail:os