2014-10-20 31 views
1

我似乎無法找到文檔中的信息iOS Realm.io限制或採取功能

我在我的應用程序中有一些簡單的聊天功能。

@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]; 

如何限制或從查詢取?我只希望最後30降序排序上createdOn財產。

回答

6

與境界,你通常不需要限制結果由於性能原因,因爲結果不會被複制,所以對查詢時間的影響可以忽略不計。

如果它是UI的原因,我們正在努力加入切片的方法來我們的查詢結果(每本主題:https://groups.google.com/forum/#!topic/realm-cocoa/VcMfk2G8iaU)。在此同時,您應該複製您有興趣成爲一個單獨的數組的結果。