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
Post a Comment