Created
July 28, 2011 18:44
-
-
Save AlanQuatermain/1112224 to your computer and use it in GitHub Desktop.
The change that fixed a HORRENDOUS CoreData-related bug which we've been chasing today.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[managedObjectContext setMergePolicy: NSMergeByPropertyObjectTrumpMergePolicy]; | |
[managedObjectContext setPersistentStoreCoordinator: coordinator]; | |
- StoreManagedObjectContextForCurrentThread( managedObjectContext ); // store in thread dictionary | |
+ | |
+ if ( [NSThread isMainThread] ) | |
+ StoreManagedObjectContextForCurrentThread(managedObjectContext); // store in thread dictionary | |
+ else | |
+ dispatch_sync(dispatch_get_main_queue(), ^{ StoreManagedObjectContextForCurrentThread(managedObjectContext); }); | |
// set some flags in the store metadata | |
NSPersistentStore * store = [[coordinator persistentStores] lastObject]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment