【发布时间】:2023-03-29 19:21:01
【问题描述】:
我想按照这些对象的RLMArray 属性的count 对RLMResults 实例包含的对象进行排序。
Person.h:
@interface Person : RLMObject
@property RLMArray *children;
@end
SomeClass.m:
...
RLMResults *people = [Person allObjects];
RLMResults *sorted = [people sortedResultsUsingProperty:@"children.count" ascending:YES];
...
如上所述使用- sortedResultsUsingProperty: 不起作用,但是会报错:Cannot sort on 'people.count': sorting on key paths is not supported.
解决这个问题的最佳方法是什么?
【问题讨论】:
-
我认为您可能只是语法稍有错误,如果您尝试使用 children.@count 会怎样?
-
我也试过了,但在这两种情况下都会出现相同的错误:
Cannot sort on 'people.@count': sorting on key paths is not supported.
标签: ios objective-c realm