【发布时间】:2014-08-14 17:17:00
【问题描述】:
我有一个NSSet 的MKAnnotations 获得者:
NSSet *locationSet = [map annotationsInMapRect:map.visibleMapRect];
然后我写一个NSPredicate 来传递所需的纬度和经度,如下所示:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"coordinate.latitude == %f AND coordinate.longitude == %f", coord.latitude, coord.longitude];
现在我尝试通过过滤集合来获取所需的对象:
NSSet *filtered = [locationSet filteredSetUsingPredicate:predicate];
MKAnnotationSubClass *mark = [[filtered allObjects] lastObject];
但是得到一个错误,说我的对象没有我传递的密钥:
由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[valueForUndefinedKey:]:此类不符合键纬度的键值编码。”`
使用纬度和经度参数过滤 NSSet 注释的正确方法是什么?
【问题讨论】:
标签: ios objective-c cocoa-touch nspredicate mkannotation