Pregunta

Estoy intentando configurar la supervisión región. Parece bastante sencillo; pero cuando puedo comprobar el número de regiones I monitor, el recuento es siempre 0.

Código:

if ([CLLocationManager regionMonitoringAvailable] &&
    [CLLocationManager regionMonitoringEnabled] ) {

    CLLocationCoordinate2D coordinate;
    double radius;

    for(Item *item in ad.proxiArray) {

        radius = [item.distance floatValue];

        coordinate= CLLocationCoordinate2DMake([item.latitude doubleValue],
                                                [item.longitude doubleValue]);
        CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:coordinate radius:radius identifier:item.place];

        NSLog(@"Adding: %@", region);

        [self.locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyNearestTenMeters];

        [region release];
    }   
    NSLog(@"region count %i",[[self.locationManager monitoredRegions] count]);
    for (CLRegion *re in [self.locationManager monitoredRegions]) {
        NSLog(@"Monitoring: %@", re);
    }
} else {
    NSLog(@"Region monitoring unavailable");
}

Cuando se ejecuta, NSLog mostrará que en realidad estoy sumando todos los puntos (sobre 10). Pero al final del bucle, como se ha dicho:

2010-12-21 12: 14: 38.172 xxxxxx [8112: 307] región recuento 0

¿Qué pasa ????

¿Fue útil?

Solución

My impression is that

  • CLLocationManager in itself is not thread-safe. Region monitoring and location monitoring will interfere and may occasionally lead to blocks (from my observation, there must be kind of a timeout, as the program continues to work after a bit more than 30 seconds)
  • Regions will be added asynchronously, thus checking the number of regions directly when having finished adding them may lead to a wrong result.
  • The accuracy is very bad (resolution of several km) when regions are actually added to be monitored

Because of these problems and the fact that region monitoring is not very accurate, I gave up the idea of using that feature.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top