4

Is there a way to save my NSManagedObjectContext in the background, off of the main thread? The save slows down how the app is performing, as it routinely takes about 2 seconds.

Costique
  • 23,712
  • 4
  • 76
  • 79
edhnb
  • 2,122
  • 3
  • 24
  • 38

1 Answers1

1

Yes, there is. Apple recommends using one context per thread to achieve that.

You can also use GCD for that, but you need to make sure that queues do not share context and you will also need to pass object ID, not the objects themselves between the queues or threads.

See this blog entry for detailed instructions: http://www.cimgf.com/2011/05/04/core-data-and-threads-without-the-headache/

coverback
  • 4,413
  • 1
  • 19
  • 31
  • The problem is getting your NSManagedObject's off the main thread context and into a background thread context to save them. But maybe that's not too slow – nielsbot Feb 19 '12 at 08:25
  • @coverback could you please edit the link , it isnt the correct one – Singh Mar 11 '16 at 12:13