gpt4 book ai didi

iphone - NSInvalidArgumentException',原因 : 'Unknown predicate type for predicate: BLOCKPREDICATE(0x70ad750)' Error

转载 作者:太空狗 更新时间:2023-10-30 03:26:10 26 4
gpt4 key购买 nike

我有一个核心数据数据库,我正在尝试使用 block 谓词创建获取请求,但我收到未知谓词错误:

NOTE: employeeToHouse is a property of type House that was created for me when I subclassed NSManagedObject

NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Place"];
request.predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
Place *sortPlace = (Place *)evaluatedObject;
CLLocation *placeLocation = [[CLLocation alloc] initWithLatitude:sortPlace.latitude.doubleValue
longitude:sortPlace.longitude.doubleValue];
CLLocationDistance distance = [placeLocation distanceFromLocation:self.userLocation];
sortPlace.distanceToUser = [NSNumber numberWithDouble:distance];
if(distance<3000)
{
return YES;
}
return NO;
}];
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@ "distanceToUser"
ascending:YES
selector:@selector(localizedCaseInsensitiveCompare:)]];

[self.loadingView removeSpinner];
[self setupFetchedResultsControllerWithFetchRequest:request];

然后我得到这个错误:

NSInvalidArgumentException', reason: 'Unknown predicate type for predicate: BLOCKPREDICATE(0x70ad750)'

我做错了什么吗?

最佳答案

据我所知,您不能将 block 谓词与 CoreData 一起使用。

在此处查看投票最多的答案:NSFetchRequest and predicateWithBlock

原因是 CoreData 无法将 block 中包含的 C 代码转换为 SQL 查询。

关于iphone - NSInvalidArgumentException',原因 : 'Unknown predicate type for predicate: BLOCKPREDICATE(0x70ad750)' Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10453448/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com