领域 - 如何查询大于 0 对象的列表
Realm - how to query for a List greater than 0 objects
我想要至少有一只猫的人的所有结果。我试过这个:
let results = realm.objects(Person.self).filter("cats.count > 0")
但是我得到这个错误:
Terminating app due to uncaught exception 'Invalid property name', reason: 'Property 'count' not found in object of type 'Cat''
人物对象如下所示:
class Person: Object {
@objc dynamic var name = ""
let cats = List<Cat>()
}
此过滤器的正确谓词是什么?
我离得太近了!
let results = realm.objects(Person.self).filter("cats.@count > 0")
(count
前需要“@”)
我想要至少有一只猫的人的所有结果。我试过这个:
let results = realm.objects(Person.self).filter("cats.count > 0")
但是我得到这个错误:
Terminating app due to uncaught exception 'Invalid property name', reason: 'Property 'count' not found in object of type 'Cat''
人物对象如下所示:
class Person: Object {
@objc dynamic var name = ""
let cats = List<Cat>()
}
此过滤器的正确谓词是什么?
我离得太近了!
let results = realm.objects(Person.self).filter("cats.@count > 0")
(count
前需要“@”)