Ios4 iPhone区域监控-未添加区域?

Ios4 iPhone区域监控-未添加区域?,ios4,monitoring,cllocationmanager,region,locationmanager,Ios4,Monitoring,Cllocationmanager,Region,Locationmanager,我正在尝试设置区域监控。看起来很直截了当;但当我检查我监视的区域数时,计数总是0 代码: 运行时,NSLog将显示我实际添加了所有项(大约10项)。但在循环结束时,如上所述: 2010-12-21 12:14:38.172 xxxxxx[8112:307]区域计数0 怎么了???我的印象是 CLLocationManager本身不是线程安全的。区域监控和位置监控会产生干扰,有时可能会导致阻塞(根据我的观察,一定会有某种超时,因为程序在30秒多一点后继续工作) 区域将异步添加,因此在完成添加区域

我正在尝试设置区域监控。看起来很直截了当;但当我检查我监视的区域数时,计数总是0

代码:

运行时,NSLog将显示我实际添加了所有项(大约10项)。但在循环结束时,如上所述:

2010-12-21 12:14:38.172 xxxxxx[8112:307]区域计数0

怎么了???

我的印象是

  • CLLocationManager本身不是线程安全的。区域监控和位置监控会产生干扰,有时可能会导致阻塞(根据我的观察,一定会有某种超时,因为程序在30秒多一点后继续工作)
  • 区域将异步添加,因此在完成添加区域后直接检查区域数量可能会导致错误的结果
  • 当实际添加要监视的区域时,精度非常差(分辨率为几公里)
由于这些问题以及区域监控不太准确的事实,我放弃了使用该功能的想法。

我的印象是

  • CLLocationManager本身不是线程安全的。区域监控和位置监控会产生干扰,有时可能会导致阻塞(根据我的观察,一定会有某种超时,因为程序在30秒多一点后继续工作)
  • 区域将异步添加,因此在完成添加区域后直接检查区域数量可能会导致错误的结果
  • 当实际添加要监视的区域时,精度非常差(分辨率为几公里)

由于这些问题以及区域监控不太准确的事实,我放弃了使用该功能的想法。

我发现iOS5上的区域监控也存在类似的不可靠性。你在iOS5上运气好吗?我在iOS5上看到了类似的区域监视的不可靠性。你运气好吗?
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");
}