我正在使用一个使用Core Data和NSManagedObjects来填充UITableView的应用程序.我的应用程序中只有一个类叫做Event.我已经创建了以下自定义实例方法Event:
- (BOOL)isExpired {
return ([[self.endOn dateAtEndOfDay] timeIntervalSinceNow] < 0);
}
Run Code Online (Sandbox Code Playgroud)
我想将UITableView显示Event对象的内容限制为仅过期的事件 - 即isExpired返回的事件YES.我试图通过添加NSPredicate到NSFetchRequest:
NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary * bindings) {return([evaluatedObject isExpired]);}];
[fetchRequest setPredicate:predicate];
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误:*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Problem with subpredicate BLOCKPREDICATE(0x272ac)'
***.这是否意味着您不能将块谓词与NSFetchRequest一起使用?或者我刚构建它不正确?
谢谢!
core-data objective-c nsfetchedresultscontroller nsfetchrequest