【发布时间】:2015-03-06 02:26:06
【问题描述】:
我们正在尝试编写一个 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 属性的大小查询所有对象?
【问题讨论】:
标签: ios swift nspredicate realm