Question

I am using a custom class to update user location. When initializing the class, I create a CLLocationManager object to be used by the class

CLLocationManager *locManager = [[CLLocationManager alloc] init];
[self setLocationManager:locManager];

The line returning a nil is CLLocationManager *locManager = [[CLLocationManager alloc] init]; which is what causes an issue.

This code works great most of the times. But on one particular device (OS Version 3.1), the init returns a nil. Any idea why CLLocationManager would return a nil on initialization?

Thanks.

Was it helpful?

Solution

When an application first initializes location services the OS asks the user if this is OK. If they say no, it's possible on subsequent runs to get nil. You may want to check for this and gracefully degrade features.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top