使用嵌套的NSPredicate SUBQUERY

Mat*_*tel 4 core-data nspredicate ios

这是我的对象图的相关部分:

Store <-->> Gift <<--> Person <<-->> Tag
Run Code Online (Sandbox Code Playgroud)

我希望能够通过tag.filtering属性过滤商店,如下所示:

ANY gifts.person.tags.filtering == YES
Run Code Online (Sandbox Code Playgroud)

但我理解为什么这不起作用,因为对一对多密钥的限制.所以我试图使用一组嵌套的SUBQUERY谓词,如下所示:

NSPredicate* filterPredicate = [NSPredicate predicateWithFormat:
   @"(0 != SUBQUERY(gifts, $x, 
     (0 != SUBQUERY($x.person.tags, $y, $y.filtering==YES).@count)).@count)"];
Run Code Online (Sandbox Code Playgroud)

这在运行时失败并出现错误:

"SQLite error code:1, 'no such column: t3.ZFILTERING'"
Run Code Online (Sandbox Code Playgroud)

看起来我在正确的轨道上,但是找不到任何其他使用相同语法的示例.我错过了什么?

Mar*_*n R 7

从我上面的评论:

[NSPredicate predicateWithFormat:@"SUBQUERY(gifts, $x, ANY $x.person.tags.filtering == YES).@count != 0"]
Run Code Online (Sandbox Code Playgroud)

工作,甚至比嵌套的SUBQUERY更简单.