领域 - 如何查询大于 0 个对象的列表



我想要至少养一只猫的人的所有结果。我试过这个:

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前需要"@"(

最新更新