Location monitoring of the main location

Does anyone know any knowledge about this:

- (void) startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy

I am trying to implement it in my project, but:

- (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region

never called?

Does anyone have sample code or do you know why this is happening?

My code is as follows. I created such a method in my own LocationManager class:

  - (void) locationManagerStartMonitoringRegion:(CLRegion *)region withAccuracy:(CLLocationAccuracy)accuracy { NSLog(@"Start Monitoring"); [locationManager startMonitoringForRegion:region desiredAccuracy:accuracy]; NSLog(@"Monitored Regions: %i", [[locationManager monitoredRegions] count]); } 

Then I call it like this:

 CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(51.116261, -0.853758); CLRegion *grRegion = [[CLRegion alloc] initCircularRegionWithCenter:coordinates radius:150 identifier:[NSString stringWithFormat:@"grRegion%i", value]]; [locationManager locationManagerStartMonitoringRegion:grRegion withAccuracy:kCLLocationAccuracyBest]; 

I get NSLog:

2011-01-30 19: 52: 26.409 TestingLocation [10858: 307] Start monitoring

2011-01-30 19: 52: 27.103 TestingLocation [10858: 307] Controlled regions:

But never get an NSLog:

  - (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@"Entered Region"); } 

or

  - (void) locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error { NSLog(@"monitoringDidFailForRegion: %@",error); } 

thanks

+6
objective-c iphone ios4 cllocationmanager cllocation
source share
5 answers

You will need to go quite a long way for the work on monitoring the region to work. Its current granularity, apparently, is based on when it is transferred from one tower with a cell to another - during my testing I had to move a mile or more to register that I finally left a small region that I established.

+5
source share

Accuracy in ios 5 improved.

+1
source share

Answer:

 - (void) startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy 

deprecated in ios 6.o. Instead, use the `- (void) startMonitoringForRegion: (CLRegion *) scope.

Thanks, Abdul`

+1
source share

Well, you can control multiple regions and simulate a location in Xcode (from the panel above the debugger) to check if it works or not. I tested and it works pretty smoothly.

+1
source share

I need to see where you are setting up your locationManager instance. But since @Mark Adams is trying to slip away, you need to set your current class as a delegate for locationManager so that it knows which class should send messages back to. It is as simple as:

locationManager.delegate = self;

0
source share

All Articles