Reputation: 40437
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?
Upvotes: 5
Views: 2139
Reputation: 6949
I have not looked at this article, but maybe you are interested in this post Passing around a NSManagedObjectContext on the iPhone by Marcus Zara.
Upvotes: 0
Reputation: 47241
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.
Upvotes: 2