Why “NOT IN” does not work in this NSPredicate?

别等时光非礼了梦想. 提交于 2019-12-05 05:24:54

Here is another idea: maybe it is trying to "negate" the bObject with the NOT. Thus, try:

@"NOT (%@ IN b)"

From the documentation:

Important You must define many-to-many relationships in both directions—that is, you must specify two relationships, each being the inverse of the other. You can’t just define a to-many relationship in one direction and try to use it as a many-to-many. If you do, you will end up with referential integrity problems.

So check this:

  1. A has a to many relationship to B.
  2. B has a to many relationship to A.
  3. The A relationship is the inverse of the B relationship.
  4. The B relationship is the inverse of the A relationship.

I think I found the answer for people coming across this question. Apparently you do need to use SELF for it to work, at least in my case with two to-many relations. This works for me:

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