ios8 - IOS Realm Swift Other Realm Accessed from incorrect thread -


i error msg *** terminating app due uncaught exception 'rlmexception', reason: 'realm accessed incorrect thread' when switch other realm. working fine when use default realm.

couldn't figure out part cause error.

let realm:realm! var queue = dispatch_queue_create("realmqueue", nil)  func init(){    var realmname = "test.realm"    let documents = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true)[0] as! string    let path = documents.stringbyappendingpathcomponent(realmname)     realm = realm(path: path) }  func loadcustomer(){      dispatch_async(queue){         //let realm = realm()         var results = self.realm.objects()          ...     }  } 

👌 bad.

dispatch_async(queue){    realm = realm(path:path) } 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -