【问题标题】:iOS Realm.io Limit or Take FunctionalityiOS Realm.io 限制或获取功能
【发布时间】:2014-10-20 03:53:15
【问题描述】:

我似乎无法在文档中找到信息

我的应用中有一些简单的聊天功能。

@interface ZPChatMessageStoredModel : RLMObject

@property NSString *content;
@property NSString *contentType;
@property NSDate *createdOn;
@property NSString *senderUserId;
@property NSString *recipientUserId;

@end

我可以像这样使用 NSPredicate 查询模型:

NSPredicate *pred = [NSPredicate predicateWithFormat:@"(senderUserId == %@ AND recipientUserId == %@) OR (senderUserId == %@ AND recipientUserId == %@)",senderUserId, recipientUserId, recipientUserId, senderUserId];

如何限制或从查询中获取?我只希望对 createdOn 属性进行降序排序的最后 30 个。

【问题讨论】:

    标签: ios objective-c realm


    【解决方案1】:

    使用 Realm,您通常不需要出于性能原因限制结果,因为结果永远不会被复制,因此对查询时间的影响可以忽略不计。

    如果出于 UI 原因,我们正在努力将切片方法添加到我们的查询结果中(根据此线程:https://groups.google.com/forum/#!topic/realm-cocoa/VcMfk2G8iaU)。同时,您应该将您感兴趣的结果复制到一个单独的数组中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-13
      • 2016-12-24
      • 1970-01-01
      相关资源
      最近更新 更多