1

When the app starts I initialise a bunch of context objects which contain to-many relationships with other entities. For instance,

  • History
  • My Tracks

wherein History and My Tracks would contain o-to-many Track entities. These are (in my current implementation) managed by a context on the main thread.

While the app is running, Track entities are created in the background and moved into History and My Tracks (which are in a different managed object context). All background threads have their own managed object context. However, when I have to save History of My Tracks, it needs to be on the main context / main thread. This is causing a significant and unacceptable UI delay while the main thread is blocked for write.

Any suggestions for a workaround?

1 Answer 1

0

There are a number of solutions available for this, and I highly recommend looking at Apple's WWDC videos in iTunes from the last two years. I'm curious as to "why" you need to save My Tracks to the main thread. Is it really that "if I don't save it there, my main context doesn't know about it"? If so, there are ways with saveChange notifications whereby the background thread can let the main context know about specific objects and such.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.