Can you prevent regions from staying between launches using the CLLocationManager?

Is there a way to prevent the CLLocationManager from persisting from controlled scopes between runs? Every time the application starts, I need to add a new set of controlled regions, and the old ones are no longer needed. Is there a way to prevent them from being saved or to clear all the old ones during startup?

+3


source to share


1 answer


Of course, you can clear all currently controlled regions:

+(void)clearRegionWatch
{
    for(CLRegion *region in [[WGLocation shared].locationManager monitoredRegions]){
        [[WGLocation shared].locationManager stopMonitoringForRegion:region];
    }
}

      

If you have a specific ID that you want to remove:



+(void)clearRegionWatchForKey:(NSString *)key
{
    for(CLRegion *region in [[WGLocation shared].locationManager monitoredRegions]){
        if([region.identifier isEqualToString:key]){
            [[WGLocation shared].locationManager stopMonitoringForRegion:region];
        }
    }
}

      

You can copy the internals of the function to the appropriate location in your application. I copied them from my general manager class.

+4


source







All Articles