hi all,

i would like to execute my couchbase operations on a dedicated dispatch 
queue within Swift. I adapted the code from this couchbase-example 
<https://github.com/couchbase/couchbase-lite-ios/blob/1a0b319fb650b8a65765f8e779a1b73aa0c19665/Source/API/APITests.m#L109>
 plus 
adding function calls referencing to self. within in the dispatch closure. 
At this point my application freeze. I attached [unowned self] to my 
closure because i thought it has of a strong reference to self but that 
doesn't help. What am i doing wrong here?

*couchbase-lite-ios-1.0.0, XCode6 Version 6.0 (6A313)*

public class MYDao {

   private var manager : CBLManager!
   private var dispatchQueue : dispatch_queue_t!

   public init(){
      //Retrieve copy of CBLManager
      self.manager = CBLManager.sharedInstance().copy()

      //Create dedicated db queue
      self.dispatchQueue = dispatch_queue_create("com.myapp.db", 
DISPATCH_QUEUE_SERIAL)

      //Assign db queue to manager
      self.manager.dispatchQueue = self.dispatchQueue
   }


   public func getDb() -> CBLDatabase {
        var database : CBLDatabase?

        //Dispatch self.manager operation on db queue
        dispatch_sync(self.dispatchQueue, {[unowned self] in
            //FREEZE
            database = self.manager.existingDatabaseNamed("mydb", error: nil)
        })

        return database;   
   }    } 

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/9fd963ca-06d9-429a-8427-f7bbc2fed95a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to