I have some doubts about NSManagedObjectContext's type.Let's see the apple's document about NSConfinementConcurrencyType:
Confinement (NSConfinementConcurrencyType)
For backwards compatibility, this is the default. You promise that context will not be used by any thread other than the one on which you created it. In general, to make the behavior explicit you’re encouraged to use one of the other types instead.
You can only use this concurrency type if the managed object context’s parent store is a persistent store coordinator.
I can't understand why this type can only be used by object context whose parent store is a persistent store coordinator. For example, I create a NSManagedObjectContext use this type, and set it's parent store to another context, is it will create some error.
The practical answer is that NSConfinementConcurrencyType
is deprecated as of iOS 9, so you shouldn't be using it at all, and the details of when it can or can't be used are irrelevant at this point.
The deeper answer, I suspect, is an aspect of the "For backwards compatibility..." part of the documentation. Queue confinement was added at the same time as nested contexts. Probably the plan was always to eventually deprecate NSConfinementConcurrencyType
, so no effort was made to update it to work with nested contexts. Only the Core Data team knows for sure, but it's likely that there are some significant bugs related to using confinement concurrency with nested contexts, but that fixing them was not a priority.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With