From what I present, realm.write () can throw an exception. In Swift 2, you handle do / catch exceptions and try.
I suspect you should do something like this:
do {
try realm.write() {
realm.add(whatever)
}
} catch {
print("Something went wrong!")
}
If realm.write () throws an exception, the print statement will be called immediately.
source
share