5
votes

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?

2
As Nick points out, the other question has a few pretty good explanations for this (particularly Ben's). Also, without breaking NDA, you may wish to read about what's changed in Lion for Core Data (which I assume will find its way to iOS 5.0).Brad Larson

2 Answers

0
votes

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.