Fetched Properties inside NSFetchedResultsController's predicate

折月煮酒 提交于 2019-12-04 15:27:52

Apparently NSPredicate can only filter using attributes that are in the database structure (this makes sense). In my case, using a subquery did the trick:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(shows, $show, $show.distance < %@).@count > 0", [SWDataManager sharedManager].localFilterDistance];

I had no idea we could do subqueries in NSPredicate, that's great to know. Credits go to @kyleve.

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