How can I debug this error and know its source:
lib
c ++ abi.dylib: terminating with uncaught exception of type realm :: IncorrectThreadException:
How can I debug this error and know its source:
lib
c ++ abi.dylib: terminating with uncaught exception of type realm :: IncorrectThreadException:
Generally this error occurs because you declare your realm outside a thread and you are using some property of it inside a thread. Example
let realm = try! Realm()
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), {
//não pode utilizar o realm declarado fora da GDC detro da GDC pois da erro de thread incorret
let pessoa = realm.objects(Pessoa).first
})
I've never messed with RealmDB, but, through the error message, it looks like you're trying to access Realm by an unauthorized thread.
I searched the Internet and found it from here:
Multi-threading with Realm
The only rule about using Realm through threads is that instances of Realm, RealmObject, or RealmResult can not be passed from one thread to another. When you want to access the same data from different threads, you should get a separate instance for each thread (through Realm.getInstance (this), for example) and access your objects through a RealmQuery. Although the objects are different, they refer to the same data on the disk and you can read and write to them from any thread!
I believe you have an instance of Realm created in some thread (in the main, for example) and is trying to access the object by another thread.
Debug suggestion:
Maybe you can find the problem out there!