Swift Couchbase Lite CBLManager dispatch_queue

96 views
Skip to first unread message

Robbie Bubble

unread,
Sep 21, 2014, 8:02:32 AM9/21/14
to mobile-c...@googlegroups.com

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 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;   
   }    
} 

Jens Alfke

unread,
Sep 23, 2014, 11:25:06 AM9/23/14
to mobile-c...@googlegroups.com
Please upgrade to the latest Couchbase Lite (1.0.2). It fixes some bugs with dispatch queues.

—Jens
Message has been deleted

Jens Alfke

unread,
Sep 26, 2014, 11:30:35 AM9/26/14
to mobile-c...@googlegroups.com

> On Sep 26, 2014, at 6:10 AM, Robbie Bubble <robbie...@gmx.com> wrote:
>
> Unfortunately i can't update because of a DDLog Library collision problem (when using CocoaPods with CocoaLumberjack-2.0.0-beta)

That was resolved in version 1.0.2.

—Jens

Reply all
Reply to author
Forward
0 new messages