ios - 如何在 objective-c 中使用 Realm.io 通过主题标签过滤帖子?

标签 ios realm

我有这样的 Post 和 Hashtag 类。

@interface Post : RLMObject
@property NSString *uID;
.....
@property RLMArray<GAHashtag *><GAHashtag> *hashtagsArray;
@end

@interface Hashtag : RLMObject
@property NSString *uID;
@property NSString *text;
@property NSInteger postsCount;
@end

我可以获取按标签文本或 uID 过滤的帖子列表吗? 例如

NSString *hashtagText = @"hello";    
RLMResults *results = [Post objectsWithPredicate:[NSPredicate predicateWithFormat:@"hashtagsArray.text ?=? %@", hashtagText]];

谢谢。:)

最佳答案

是的。您可以使用 ANY 运算符按主题标签或 uID 过滤帖子。请尝试如下:

RLMResults *results = [Post objectsWhere:@"ANY hashtagsArray.text = %@", hashtagText];

关于ios - 如何在 objective-c 中使用 Realm.io 通过主题标签过滤帖子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33709119/

相关文章:

ios - 如何使用 iOS 上的 Instruments 验证 TableView 中标签的名称?

ios - 我的应用程序很慢,如何读取这个 Xcode 工具

ios - UICollectionView 和 UINavigationController 不合作 - 设置提示时导航 Controller 遮挡单元格

ios - 保留或批处理 Realm 通知?

swift Realm 在后台线程中然后应用程序崩溃

ios - 如果 navigationBar.translucent 为 NO,则 UITableView 底部区域保持在屏幕之外;

ios - 如何从 UITextView 中删除垂直线并在 DALinedTextView 中从左侧键入文本?

swift - 如何在 MKAnnotation CalloutAccessoryView 中显示所选图像,swift 2.2

android - 使用 addRealmObjectField 添加新架构时出现 RealmMigrationNeededException

react-native - 无法在写入事务之外修改托管对象 - React Native、Realm