【发布时间】:2011-03-30 01:44:30
【问题描述】:
我有 3 个实体。文件夹、Feed 和 FeedItem
我需要获取包含未读 FeedItem 的提要和提要的文件夹
NSPredicate * predicate = [NSPredicate predicateWithFormat:@" feeds.@count > 0 AND feeds.feedItems.unread == 0 "];
我收到此错误
'NSInvalidArgumentException',原因:'to-many key not allowed here'
如何构造这样的谓词?有可能吗?
【问题讨论】:
-
您可以尝试在异常对象的
userInfo中查找谓词,您可以检查该表达式的哪个部分无效。predicateWithFormat:创建一棵 NSPredicates 树(在您的情况下由 NSComparisonPredicates 和 NSCompoundPredicates 组成)并返回该树的根;如果异常对象在其userInfo中有谓词,它将是该树的节点之一,对应于该表达式的某些部分。
标签: iphone cocoa cocoa-touch core-data