views:

242

answers:

2

If a user has location services on, I assign my RootController as its delegate:

appDelegate.clLocationManager.delegate = self;

where appDelegate is an instance of my application delegate, which is where I have the location services instance. clLocationManager is an instance of CLLocationManager. If I discover the user is outside of a certain region, I want to disable location service delegates. I do this:

appDelegate.clLocationManager.delegate = nil;

But this method still fires:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation

Is there another way to disable location services or at least keep its methods from firing?

+1  A: 

Yes, you need to tell it to stop updating location:

[appDelegate.clLocationManager stopUpdatingLocation];

After that you can also release it.

See the documentation for details.

calmh
Thanks. I tried that but didUpdateToLocation fires three more times after calling stopUpdatingLocation. Shouldn't it stop updating immediately?
4thSpace
For it to work, I had to release and then immediately alloc the location manager.
4thSpace