NSInvalidArgumentException',原因:'谓词的未知谓词类型:BLOCKPREDICATE

时间:2013-11-19 08:27:44

标签: ios core-data objective-c-blocks nspredicate distance

我有NSPredicate这样:

 CLLocationDistance maxDistance = 100.0;
 CLLocation *currentLocation = XXX;      
 NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id smallAccount, NSDictionary *bindings) {
                        TestObj *acc = [smallAccount valueForKey:@"key"];

                        double lon = [[acc valueForKey:LONGITUDE] doubleValue];
                        double lat = [[acc valueForKey:LATITUDE] doubleValue];
                        CLLocation *locObj = [[CLLocation alloc] initWithLatitude:lat longitude:lon];

                        return [locObj distanceFromLocation:currentLocation] <= maxDistance;
                    }];

我需要用距离谓词来获取对象。如果我使用此代码,我有错误

  

NSInvalidArgumentException',原因:'未知的谓词类型   谓词:BLOCKPREDICATE

我理解我不能使用这个谓词有一些动作。但我无法改变,而且数据库中的对象。我怎么解决这个问题?我可以以某种方式写另一个块?请帮忙

0 个答案:

没有答案