Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSManagedObjectContext and GCD

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?

like image 882
samvermette Avatar asked Nov 06 '22 00:11

samvermette


1 Answers

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.

like image 73
Nick Weaver Avatar answered Nov 09 '22 14:11

Nick Weaver