Setting Up Default Data

When a Core Data project is first set up, there is no data in it. Although this might work for some use cases, frequently it is a requirement to have some data prepopulated in the app for the first run. In the sample app there is a custom data setup class called ICFDataStarter, which illustrates how to populate Core Data with some initial data. A #define variable is set up in MyMovies-Prefix.pch called FIRSTRUN, which can be uncommented to have the app run the logic in ICFDataStarter.

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.