NSPredicate for to-many relationship, where a relationship (NSSet) must contain Entities defined in an NSArray

£可爱£侵袭症+ 提交于 2019-12-02 05:27:18

Does

[NSPredicate predicateWithFormat:@"A==%@ AND (ALL %@ IN Bs)", Ax, myArray];

do what you expect? I am not sure (and away from my OS X box) whether this predicate is translatable to SQL for the Core Data SQLite engine. You may need a SUBQUERY expression:

[NSPredicate preidcateWithFormat:@"A==%@ and SUBQUERY(Bs, $x, $x IN %@).@count == %d", Ax, myArray, myArray.count];

This assumes that the items in myArray are unique.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!