Saves are very slow with CBLIncrementalStore

32 views
Skip to first unread message

tho...@popina.com

unread,
Jun 11, 2015, 2:01:39 PM6/11/15
to mobile-c...@googlegroups.com
Hi,

Before integrating couches lite iOS, we used this good practice : http://martiancraft.com/blog/2015/03/core-data-stack/

We have two separate contexts, a main context used in every controllers, and a private context, parent of the previous, used to persist save on disk.

Here's an example :

    self.parentContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];

    [self.parentContext setPersistentStoreCoordinator: coordinator];


    self.context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];

    self.context.parentContext = self.parentContext;


    [incrementalStore addObservingManagedObjectContext:self.context];

    [incrementalStore addObservingManagedObjectContext:self.parentContext];


But that doesn't work : THREAD-SAFETY VIOLATION: This database is being used on a thread it wasn't "

              " created on! Please see the concurrency guidelines in the Couchbase Lite "

              "documentation.


So my question is : what's the best practice to perform a save that doesn't slow the UI ?


Thanks

Reply all
Reply to author
Forward
0 new messages