我有两个NSManagedObjects,如下所述。
extension Day {
@NSManaged var date: NSDate?
@NSManaged var isHighPriority: NSNumber?
@NSManaged var projects: NSSet?
}
extension Project {
@NSManaged var complete: Bool
@NSManaged var title: String?
@NSManaged var day: Day?
}
我想要做的是获取完成所有Day
的所有Projects
个对象。但是,当我尝试此获取请求时,我收到此错误。 Exception was caught during NSPersistentStoreCoordinator -performBlock: Unsupported predicate
这是我的谓词
let predicate = NSPredicate(format: "isHighPriority == %@ AND ALL projects.complete == TRUE", NSNumber(bool: true))
如何正确获取集合中每个Day
已完成的所有Project
?我可以获取然后filter
,但我宁愿在CoreData级别完成所有操作。
答案 0 :(得分:0)
我可以通过在SUBQUERY
NSPredicate
来执行此操作
let predicate = NSPredicate(format: "isHighPriority == %@ AND SUBQUERY(projects, $project, $project.complete == TRUE).@count == projects.@count", NSNumber(bool: true))