1
How can I debug this error and know its origin:
lib
c++Abi.dylib: terminating with uncaught Exception of type Realm ::Incorrect threadexception: Realm accessed from incorrect thread.
1
How can I debug this error and know its origin:
lib
c++Abi.dylib: terminating with uncaught Exception of type Realm ::Incorrect threadexception: Realm accessed from incorrect thread.
2
Usually this error occurs because you declare your Realm outside a thread and are using some property of it within 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
})
1
I’ve never messed with Realmdb, but from the error message, it looks like you’re trying to access Realm from an unauthorized thread.
I searched the Internet and found this here:
Multi-threading with Realm
The only rule regarding the use of Realm through threads is that instances of Realm, Realmobject or Realmresult cannot 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 its objects through a Realmquery. Although the objects are different, they refer to the same data on the disk and it will be possible to read and write on them from any thread!
I believe you have an instance of Realm created in some thread (in the main, for example) and are trying to access the object by another thread.
Debug suggestion:
Maybe you can find the problem out there!
Browser other questions tagged swift thread multithreading commit realmdb
You are not signed in. Login or sign up in order to post.
Vlw!!! I managed to solve but forgot to put here!!
– Tiago Amaral