From 1deecbd301ba229efa29e77a7311c2439fb2fd76 Mon Sep 17 00:00:00 2001 From: Frank O'Dwyer Date: Thu, 1 Mar 2012 20:20:53 +0000 Subject: [PATCH 1/2] Create contexts on the thread where they will be used --- .../NSManagedObjectContext+DCTAsynchronousTasks.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Asynchronous/NSManagedObjectContext+DCTAsynchronousTasks.m b/Asynchronous/NSManagedObjectContext+DCTAsynchronousTasks.m index f7990e7..6c78e9f 100644 --- a/Asynchronous/NSManagedObjectContext+DCTAsynchronousTasks.m +++ b/Asynchronous/NSManagedObjectContext+DCTAsynchronousTasks.m @@ -189,13 +189,13 @@ - (void)dct_asynchronousTaskWithObjects:(NSArray *)objects [objectIDs addObject:[mo objectID]]; } - NSManagedObjectContext *threadedContext = [[NSManagedObjectContext alloc] init]; - [threadedContext setPersistentStoreCoordinator:[self persistentStoreCoordinator]]; - dispatch_queue_t asyncQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(asyncQueue, ^{ + NSManagedObjectContext *threadedContext = [[NSManagedObjectContext alloc] init]; + [threadedContext setPersistentStoreCoordinator:[self persistentStoreCoordinator]]; + NSArray *threadedObjects = nil; if (objectIDs) { NSMutableArray *array = [NSMutableArray arrayWithCapacity:[objectIDs count]]; @@ -246,13 +246,13 @@ - (void)dct_asynchronousFetchRequest:(NSFetchRequest *)fetchRequest withCallbackQueue:(dispatch_queue_t)callbackQueue block:(DCTFetchRequestCallbackBlock)callbackBlock { - NSManagedObjectContext *threadedContext = [[NSManagedObjectContext alloc] init]; - [threadedContext setPersistentStoreCoordinator:[self persistentStoreCoordinator]]; - dispatch_queue_t asyncQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(asyncQueue, ^{ + NSManagedObjectContext *threadedContext = [[NSManagedObjectContext alloc] init]; + [threadedContext setPersistentStoreCoordinator:[self persistentStoreCoordinator]]; + NSError *error = nil; NSArray *array = [threadedContext executeFetchRequest:fetchRequest error:&error]; From 4e9a83add41fffd428203ebca398eb3af5d58964 Mon Sep 17 00:00:00 2001 From: Frank O'Dwyer Date: Sun, 24 Jun 2012 01:56:18 +0100 Subject: [PATCH 2/2] added gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store