【发布时间】:2013-01-27 19:45:30
【问题描述】:
我正在开发一个有 Post 对象的应用程序,每个 Post 可以有许多实体(提及、主题标签和链接),每个实体都有一个 Post。我有一个实体的主类,然后我有三个子类。
Mention : Entity
我的提及类具有以下属性:
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSNumber * userId;
我现在想创建一个 NSPredicate 来查找所有提及某个用户和 userId 的帖子,但我不知道该怎么做。
我已经尝试过这样的一些事情:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY mentions.userId like %@", [Session currentUser].userId];
// That doesn't work since Post(s) have many entities and not Mention(s).
// I have also tried something like this:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY entities.mentions.userId like %@", [Session currentUser].userId];
// And that didn't work either.
关于如何最好地找到所有提及具有特定 userId 的特定用户的帖子有什么想法吗?
【问题讨论】:
标签: ios cocoa-touch core-data nspredicate