|
6
9
|
I've seen a few videos / threads that say it's possible to create 'children' MOCs -- MOCs that use other MOCs as their persistant stores. Useful, for example, in a context where you're threading your application, and want to have a single master MOC that can save / rollback the changes that the child threads create. (From what I understand, a MOC and it's managedObjects MUST all be used on the same thread) The question is, how do I create a child MOC? I can't track down the WWDC videos I was watching that introduced them, and everything I"ve seen has been talking about how to use them ONCE they're made. I can easily alloc a new MOC, but how do I set it's persistent store to be another MOC? The reference doesn't show any functions that do that! | |||
| add comment |
|
16
|
Create a new MOC for which you are in total control of the synchronization. This is the same as calling
You parent a MOC to another MOC by setting its property:
Here, the child chooses the parent. I'm sure my kids wish they were NSManagedObjectContexts. A parent context must be of either You can create a MOC that is "bound" to a private queue:
which means you should only access it via the
The difference between You can also create a MOC that is "bound" to the main thread, just like private concurrency.
which means you should only access it directly if you know you are on the main thread, or via the Now, you can use the "main concurrency" MOC either via the | ||||||||||||
|
|
1
|
Initialize child MOC then:
| ||||||||
|

1366








