stopMonitoringForRegion with dummy lat long but the right "identifier"

cllocationmanager, iphone, objective-c

Solution

You need to pull the correct region to disable the monitoring. What I would do is loop through all the regions enabled and just stop monitoring the one that matches your identifier.

for (CLRegion *region in [locationController.locationManager monitoredRegions]) {
    if (region.identifier isEqual:yourIdentifier]) { // change this to match your identifier format
        [locationController.locationManager stopMonitoringForRegion:region];
    }
}

Problem

I am scheduling and canceling region monitoring in my app as follows. ``` - (void) setLocationReminderForLatitude:(double) latitude longitude:(double) longitude radiusInMetres:(double) radius withIdentifier:(NSString *) identifier { CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:CLLocationCoordinate2DMake(latitude, longitude) radius:radius identifier:identifier]; [coreLocation startMonitoringForRegion:region desiredAccuracy:50]; //50 metres } - (void) cancelLocationNotification:(NSString *)identifier { CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:CLLocationCoordinate2DMake(0.0, 0.0) radius:100.0 identifier:identifer]; [coreLocation stopMonitoringForRegion:region]; } ``` While canceling the region monitoring, I might not necessarily have the centre and radius information that I initially used to start monitoring that region, but the identifier is right. Will this work? The documentation doesn't mention anything about that.

Original source