Last active
July 10, 2017 18:21
-
-
Save insidegui/dc41d2e523148bb2bfb43f8ef793fe83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ModelObject: Object { | |
@objc public override func setValue(_ value: Any?, forKey key: String) { | |
// make sure we begin a write transaction if this is a managed object | |
self.realm?.beginWrite() | |
// actually do the update | |
super.setValue(value, forKey: key) | |
// commit the write transaction if managed | |
// this will crash if the write fails, in the real world you'd want to use do { } catch { } | |
try! self.realm?.commitWrite() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment