Reputation: 4955
My setup:
NSManagedObjectContext
with type NSPrivateQueueConcurrencyType
that is connected to my NSPersistentStoreCoordinator
NSManagedObjectContext
with type NSMainQueueConcurrencyType
that is a child of the private context.NSManagedObjectContext
with type NSConfinementConcurrencyType
that is a child of the main context.While downloading data from a server, I write data to the context of type NSConfinementConcurrencyType
. I then save this context, which pushes changes to my main context. I then save my main context, which pushes changes to my private context. At this point, I use the performBlock
method on the private context to save everything to my persistent store.
This works flawlessly when debugging on a device. Whenever I archive the application and run the application in release mode, my main context never receives changes even though I successfully save it's child context. I have double checked and my temporary context is indeed linked to the main context (the main context does show up as the temporary context's parent). But whenever I save the temporary context in release mode, the main context never shows any changes. I'm baffled as to why this would work in debug mode but not in release.
Any suggestions/help would be greatly appreciated.
Thanks,
groomsy
EDIT: If I archive the build using the Debug configuration, everything works as expected. Therefore there is some setting in the Release configuration that is different. I will report back with what I find.
EDIT 2: Found the culprit. So I had wrapped my save context calls in an NSAssert (in hopes of catching any failures while testing). Unfortunately, the Release configuration stripped out these assertion blocks which housed my save calls. face palm
Upvotes: 0
Views: 169
Reputation: 7646
NSConfinementConcurrencyType
is the old legacy Core Data behavior, before the notion of parent and child contexts. If you're doing an import into a child context, that child needs to be NSPrivateQueueConcurrencyType
. I'm surprised that the combination of performBlock:
, parent/child MOCs, and NSConfinementConcurrencyType
works at all.
Upvotes: 1