overcommitted / ParcelKit

ParcelKit integrates Core Data with Dropbox using the Dropbox Datastore API
MIT License
567 stars 38 forks source link

updateCoreDataWithDatastoreChanges - managed object context on wrong thread #20

Closed lyahdav closed 10 years ago

lyahdav commented 10 years ago

It seems that the method sets up a managed object context with PrivateQueueConcurrencyType. However, the code seems to be running on main thread as it does not use performBlock. This could be a possible fix:

    NSManagedObjectContext *managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
    [managedObjectContext setPersistentStoreCoordinator:[self.managedObjectContext persistentStoreCoordinator]];
    [managedObjectContext setUndoManager:nil];

    [managedObjectContext performBlockAndWait:^{
        __block NSMutableArray *updates = [[NSMutableArray alloc] init];
...
daikini commented 10 years ago

This has been fixed in 969082df70ddd34f999bd5121bd72d0f818b4b4f.