A rough example of how to set up a Core Data stack based on the talk by Marcus Zarra (@mzarra) at MCE 2015 (https://www.youtube.com/watch?v=ckbke8vjHMw)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
CoreDataStackSetup.xcodeproj
CoreDataStackSetup
.gitignore
LICENSE
README.md

README.md

CoreDataStackSetup

Please also see Marcus' own blog post and code explaining his own Core Data stack at http://martiancraft.com/blog/2015/03/core-data-stack/.


This is a rough example of how to set up a Core Data stack based on the talk by Marcus Zarra (@mzarra) at MCE 2015 (https://www.youtube.com/watch?v=ckbke8vjHMw).

This code has not been checked by or approved by Marcus, it is simply my interpretation of his talk.

Points To Note

  • A good approach to setting the Core Data stack up is to configure your UI but disable or hide elements which cannot function until the stack setup is complete. Then call setupCoreDataStackWithCompletionHandler: which uses a block-based handler to return whether this was successful or not. If setup was successful you can enable and show the UI elements and refresh tables, etc.
  • OTSMainViewController includes an addDataItem: method which allows you to add single items to the database. Each time an item is added the MOC performs a save.
  • OTSMainViewController also includes an addMultipleDataItems: method which adds several items to the database on a separate MOC which is a child of the main thread MOC. This method shows how to create a child MOC, and use its performBlock: method to do data manipulation without affecting the main thread MOC.