我们正在尝试编写Realm查询以检索RLMArray属性的大小为一定数字的所有对象。Realm模型如下所示:
class Foo: RLMObject {
dynamic var people = RLMArray(objectClassName: User.className())
}
我们尝试了多次但没有成功的查询迭代,如下所示:
// 'Invalid predicate expressions', reason: 'Predicate expressions must compare a keypath and another keypath or a constant value'
let results = Foo.objectsWhere("people[SIZE] = %d", 2)
// 'Invalid predicate', reason: 'RLMArray predicates must contain the ANY modifier'
let results = Foo.objectsWhere("people.@count = %d", 2)
// 'Invalid column name', reason: 'Column name @count not found in table'
let results = Foo.objectsWhere("ANY people.@count = %d", 2)
我们浏览了多个示例,其中包括Apple关于NSPredicate的文档以及其他SO答案,但似乎找不到答案。我们如何根据RLMArray属性的大小查询所有对象?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句