[英]Multiple to-many NSPredicate
I have a model with a couple of to-many relationships. 我有一个具有一对多关系的模型。
System ->> Item ->> Code 系统->>项目->>代码
I'm trying to write a predicate on a fetchRequest for System. 我正在尝试在fetchRequest for System上写一个谓词。
I only want to show Systems that have Items that have at least one Code. 我只想显示具有至少具有一个代码的项目的系统。
I have tried a SUBQUERY but I just can't get it to work. 我尝试了一个SUBQUERY,但无法正常工作。
This is what I've tried... 这就是我尝试过的...
[NSPredicate predicateWithFormat:@"(SUBQUERY(items, $x, $x.codes.@count != 0) != 0)"];
I've tried other various permutations of this but they all throw similar errors. 我尝试了其他各种排列方式,但是它们都引发了类似的错误。
Could someone let me know what the correct predicate format is? 有人可以让我知道正确的谓词格式吗?
我认为你必须添加其他@count
子查询:
[NSPredicate predicateWithFormat:@"SUBQUERY(items, $x, $x.codes.@count != 0).@count != 0"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.