为什么“不输入”不工作在这个NSPredicate? [英] Why "NOT IN" does not work in this 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
andB
.a
are inverse to-many relationships. Why does this predicate forA
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
A
s that have no relation withbObject
viaa<-->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 byAccount
.filtered_clients
andB
.a
is embodied byClient
.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 theNOT
. Thus, try:@"NOT (%@ IN b)"
这篇关于为什么“不输入”不工作在这个NSPredicate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!