From Apple's Core Data Programming Guide:
You should give each thread its own entirely private managed object context and keep their associated object graphs separated on a per-thread basis.
How does that scale to Grand Central Dispatch, where you have absolutely no control over threads, which are created automagically on your behalf?
The way I do it now is to have one NSManagedObjectContext
for each dispatch queue, but that's the thing: a dispatch queue doesn't necessarily use the same thread every time, right?
I think "What does Apple mean when they say that a NSManagedObjectContext is owned by the thread or queue that created it?" on SO will answer your question.
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