我有以下对象模型:
class Work: Object {
@objc dynamic var id = 0
@objc dynamic var firstName: String? = nil
@objc dynamic var lastName: String? = nil
@objc dynamic var jobDesc: String? = nil
@objc dynamic var avatar: String? = nil
@objc dynamic var isInvited = 0
@objc dynamic var typeContact = 0
override static func primaryKey() -> String? {
return "id"
}
所以我希望得到所有行的选定作品,但只有isInvited是1.这是否可以在领域中筛选检索对象中的列表?
答案 0 :(得分:1)
试试这个 - 领域过滤器
let realm = try! Realm()
let Works = realm.objects(Work.self).filter("isInvited == 1")
有关更多详细信息,请参阅领域文档 https://realm.io/docs/swift/latest/