在使用Core Data的xCode项目中,我有两个实体:Article和ArticleMarket。他们是一对多的关系,一篇文章有n条文章。
我必须检索所有尊重此NSPredicate
"SUBQUERY(markets, $m, " +
"$m.startVisibility <= /*TODAY*/ AND " +
"$m.sellDate <= /*TODAY*/ AND " +
"$m.outSellDate >= /*TODAY*/ AND " +
"$m.state = '1' AND " +
"$m.maxXOrder != 0" +
").@count > 0"
如果文章有&#34;市场&#34;这将起作用。收集领域就像一段感情。问题是该字段是Fetched Property
:我无法建立关系,因为我必须将每个ArticleMarket链接到相应的文章,而且我有数千篇文章。
因此,该谓词适用于Relationships,但不适用于Fetched Properties。它给了我这个错误:
Can't have a non-relationship collection element in a subquery
我试过这个:我可以直接在Fetched属性谓词中输入该谓词吗?这就是结果:
$FETCH_SOURCE.id == articleId AND
startVisibility <= /*TODAY*/ AND
sellDate <= /*TODAY*/ AND
outSellDate >= /*TODAY*/ AND
state = '1' AND
maxXOrder != 0
好的,我把它放在/ TODAY /?
上提前致谢,我很抱歉英语不好,希望问题很清楚!