Core data subquery predicate

被刻印的时光 ゝ 提交于 2019-11-29 13:15:09

Have you tried (untested):

[NSPredicate predicateWithFormat:@"SUBQUERY(games, $g, $g.kickOffDate >= %@ AND $g.kickOffDate <= %@).@count > 0", [self startOfDay:[NSDate date]],[self endOfDay:[NSDate date]]];

== League that have a game with a kick-off date in a given range

Your solution is equivalent to:

[NSPredicate predicateWithFormat:@"ANY games.kickOffDate >= %@ AND ANY games.kickOffDate <= %@",start,end];

== League that have a game that start after a given date and have a game that start before a given date (could be different games, or the same game)

Which should return more results than you like.

Edit:
As @Martin R suggested, you should verify that your data does indeed include a League answering the predicate to test it.
If you still get no results, check to see if there were errors during execution of the request and your data-stack is properly initialized.

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