为什么“不输入”不工作在这个NSPredicate? [英] Why "NOT IN" does not work in this NSPredicate?

查看:98
本文介绍了为什么“不输入”不工作在这个NSPredicate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

A b B c $ c> a 是多对数关系。为什么 A 的此谓词有效:

  NSPredicate * predicate = NSPredicate predicateWithFormat:@NOT SELF IN%@,bObject.a]; 

,但这不:

  NSPredicate * predicate = [NSPredicate predicateWithFormat:@NOT%@ IN b,bObject]; 



我想两个谓词应该给出相同的结果 - A bObject 通过 a < - > b 没有关系。



更新:






这里是一个示例项目,其中 A b 体现为帐户 filtered_clients B a 由客户 MasterViewController.m 切换第143行和第144行的注释。

看到差别。



请帮助我找到我的代码中的错误,或确认它是一个核心数据错误,报告给苹果。非常感谢。

解决方案

这里是另一个想法:也许是试图否定 bObject NOT 。因此,请尝试:

  @NOT(%@ IN b)
/ pre>

A.b and B.a are inverse to-many relationships. Why does this predicate for A work:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT SELF IN %@", bObject.a];

while this one does not:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT %@ IN b", bObject];

I think both predicates should give the same result — the collection of As that have no relation with bObject via a<-->b. But in fact, the first one gives the correct collection while the second one not.

Update:


Here is a sample project wherein A.b is embodied by Account.filtered_clients and B.a is embodied by Client.filtered_by.

Toggle commenting of line 143 and line 144 in MasterViewController.m to see the difference.

Please help me either find the bug in my code, or confirm it is a Core Data bug so I can report it to Apple. Thanks very much.

解决方案

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

@"NOT (%@ IN b)"

这篇关于为什么“不输入”不工作在这个NSPredicate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆