有谁知道在 Realm.io 中是否有这个查询的等效表达式?我需要按“dreamDate”属性分组的结果
// Search all dreams grouped by date
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"user == %@ AND parseSyncDeleted == false", user];
NSFetchedResultsController *groups = [Dream MR_fetchAllGroupedBy:@"dreamDate.dateWithoutTime"
withPredicate:predicate
sortedBy:@"dreamDate"
ascending:YES];
return groups;
dreamDate -> NSDate 属性
dateWithoutTime -> 将其转换为不带时间组件的 NSDate 的类别
谢谢!
最佳答案
Realm 没有用于对结果进行分组的内置数据结构,但您可以通过持有 RLMResults 的 NSArray 或 NSDictionary 来非常轻松高效地完成此操作。请参阅 GroupedTableView 示例了解如何执行此操作:https://github.com/realm/realm-cocoa/blob/master/examples/ios/objc/GroupedTableView/TableViewController.m
关于ios - 等价查询 MagicalRecord -> Realm.io,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29095483/