Skip to content

Instantly share code, notes, and snippets.

@owenzhao
Created September 4, 2016 22:05
Show Gist options
  • Save owenzhao/be8eefdaf24d79ea3c72e93ec7842c23 to your computer and use it in GitHub Desktop.
Save owenzhao/be8eefdaf24d79ea3c72e93ec7842c23 to your computer and use it in GitHub Desktop.
Realm的坑(二)
let bar = Foo()
bar.name = "Marry" // ok
let realm = try! Realm()
try! realm.write {
realm.add(bar)
bar.name = "Kelly" // ok
}
bar.name = "Jimmy" // *** Terminating app due to uncaught exception 'RLMException', reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment