CoreData - 如果关系有数据,则 NSPredicate 结果
我在表之间存在多对多关系,并使用活动填充 tableView。 为此,我使用一个简单的 NSPredicate,如下所示:
request.predicate = [NSPredicate predicateWithFormat:@"deleted == %@", [NSNumber numberWithBool:NO]];
我怎样才能只显示具有成员的活动附在它上面?
我认为在 NSPredicate 中我必须进行一些计数,以便只有 count > 的 Activity 才有效。返回 0。是这样吗? 如何?
(我是 coredata 的新手...)
谢谢,
RL
I have a many-to-many relationship between tables, and I populate a tableView with Activities.
For that i user a simple NSPredicate like this:
request.predicate = [NSPredicate predicateWithFormat:@"deleted == %@", [NSNumber numberWithBool:NO]];
How can I do to show only the Activities that has Members attached to it?
I think that in the NSPredicate I have to do some count so that only the Activities with count > 0 are returned. Is that so?
How?
(i'm newbie in coredata...)
Thanks,
RL
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要向作用于 CompanyActivity 实体的谓词添加一个子查询,如下所示:
谓词的第一部分返回尚未删除的对象,与子查询相关的第二部分将负责检索其成员已删除的所有 CompanyActivity 对象。没有被删除。
You need to add a subquery to your predicate acting on the CompanyActivity entity as follows:
The first part of the predicate returns objects which have not been deleted, the second one related to the subquery will take care of retrieving all those CompanyActivity objects whose Members have not been deleted.