Reputation: 153
I am beginning to get extremely frustrated with MapKit. First of all, I have
if (manager.authorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse) {
}
Which is failing to build because it says "Property 'authorizationStatus' not found on object of type 'CLLocationManager *'. Seriously? Because not only am I sure that CLLocationManager is supposed to have an authorizationStatus property as per the Apple Documentation https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html but it also autocompletes the property as I type it. I have literally no idea what to do now.
On top of that, I have
if (!manager) {
NSLog(@"manager created in viewDidLoad");
manager = [[CLLocationManager alloc]init];
manager.delegate = self;
[manager requestWhenInUseAuthorization];
NSLog(@"manager is supposed to ask for permission");
}
And both NSLog statements are getting called, but authorization is not being asked for and so I get an error. Yes, I have also added the necessary key strings in my plist file, because the app is working on my phone, but on other people's phones I am getting this error. The only possible explanation is that I'm trying to use MapKit BEFORE asking for permission, but I have checked thoroughly for that and haven't found anything like that. It also isn't even showing the alert box to ask for permission.
If anyone can help with these bugs, it would be greatly appreciated. I have nothing to do until then because I have already tried everything.
EDIT: I figured out the problem. I had the two plist keys NSLocationWhenInUseUsageDescription
and NSLocationAlwaysUsageDescription
... Only one of them was slightly spelled wrong. The Apple API doesn't make the call if the plist entry is missing or spelled incorrectly and does not warn you.
Incredible.
Upvotes: 1
Views: 1885
Reputation: 60140
+authorizationStatus
is a class method on CLLocationManager, not a property. You invoke it as:
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse) {
//...
}
This is denoted by the use of a +
in front of the method name (instead of a -
, which would indicate an instance method, or the lack of symbol that generally accompanies properties).
Upvotes: 15