Sunday, December 20, 2015 [Tweets] [Favorites]

Core Data Threading Demystified

Marcus Zarra (comments):

In the best way, we go back to having one PSC, but we’re going to use the new APIs in iOS 6. We’re going to add a private MOC that talks to that PSC. Then, we’re going to add our main context and define it as a main context, and we’re going to make that a child of that private MOC. Any data processing will be below the main MOC, so we will have three levels of contexts.

[…]

This design allows us to have asynchronous saves, which is extremely important. It allows us to save and to consume or process data without blocking the UI. A user can happily scroll through our application, look at data, play with it, and we’re not telling them that they have to wait for us.

[…]

We have an extra level of indirection between the PSC and the main MOC, so we will get a little bit of slowness there. When I say little bit, I mean if I build up a test case it does thousands upon thousands of iterations, I will find a 1-2% variance in the speed.

[…]

You can use notifications to force one child to consume updates from the other child, but don’t do this. It’s just a bad idea.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment