SUBQUERY in core data

非 Y 不嫁゛ 提交于 2019-12-29 06:31:12

问题


I can't understand what's wrong with my predication. I have the next database scheme:

DataItem(color_ids) <->> (dataItem)Color

Where Color contains colorID(int).

I tried to get

all DataItems that contain colorID == 5.

I have used the next predicate:

SUBQUERY(color_ids, $sub, $sub.colorID==5).@count > 0

Thanks for your help.


回答1:


You don't need SUBQUERY for this. In fact, you almost never need SUBQUERY; it is extremely rare to find a situation where it is the correct thing to use.

You can do this instead:

[NSPredicate predicateWithFormat:@"ANY color_ids.colorID == 5"];


来源:https://stackoverflow.com/questions/6890079/subquery-in-core-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!