RealmSwift更新记录性能

时间:2018-08-27 13:52:07

标签: swift performance realm

其中哪些会表现更好:

let personId = 1234
let realm = Realm()
let retrievedPerson = realm.object(Person.self).first {return $0.id == personId}
if let retrievedPerson = retrievedPerson {
      retrievedPerson.lastUpdated = 2004
}

OR

let personId = 1234
let realm = Realm()
let realmPerson = RealmPerson(personId)

realm.write { 
    realm.add(person,update: true) 
}

0 个答案:

没有答案