CLregions の配列があり、これが私のコードです:
NSArray *_regionArray;
NSArray *_geofences_regions;
... in the ViewDidLoad
_geofences_regions = [self buildGeofenceData];
....
- (NSArray*) buildGeofenceData {
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"regions" ofType:@"plist"];
_regionArray = [NSArray arrayWithContentsOfFile:plistPath];
NSMutableArray *geofences = [NSMutableArray array];
for(NSDictionary *regionDict in _regionArray) {
CLRegion *region = [self mapDictionaryToRegion:regionDict];
[geofences addObject:region];
}
return [NSArray arrayWithArray:geofences];
}
- (CLRegion*)mapDictionaryToRegion:(NSDictionary*)dictionary {
NSString *title = [dictionary valueForKey:@"title"];
CLLocationDegrees latitude = [[dictionary valueForKey:@"latitude"] doubleValue];
CLLocationDegrees longitude =[[dictionary valueForKey:@"longitude"] doubleValue];
CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(latitude, longitude);
CLLocationDistance regionRadius = [[dictionary valueForKey:@"radius"] doubleValue];
return [[CLRegion alloc] initCircularRegionWithCenter:centerCoordinate
radius:regionRadius
identifier:title];
}
次のコードでは、the property identifier is not found on object of type id
.
何故ですか?_geofences_regios[i]
CLRegion を返すべきではありませんか?
/*check for region*/
CLLocationCoordinate2D coordinate = [bestLocation coordinate];
for (int i=0; i<[_geofences_regions count]; i++) {
if ([_geofences_regions[i] containsCoordinate:coordinate]) {
[self.delegate locationManager:self regionEntered:_geofences_regions[i].identifier ];
} } /リージョンのチェックを終了/
上記の質問に答えてください。didEnterRegion のような他のデリゲート メソッドを使用することを提案しないでください。
ありがとう!