【发布时间】:2011-10-09 22:24:59
【问题描述】:
是否可以使用 CLLocation 对象作为字典中的键?当我尝试这个时,[dictionary objectForKey: clLocationObj] 总是返回 nil,即使已经插入了完全相同的纬度和经度的 CLLocation 键。我可能做错了什么?
for (Location *location in someArray) {
CLLocation *locationKey = [[CLLocation alloc] initWithLatitude:[location.latitude doubleValue] longitude:[location.longtitude doubleValue]];
LocationAnnotation *annotationAtLocation = [self.uniqueLocations objectForKey:locationKey];
if (annotationAtLocation == nil)
NSLog(@"this is always nil");
}
我从调试中得知,someArray中有多个经纬度相同的Location对象。
【问题讨论】:
标签: objective-c ios4 mapkit core-location