Seeding a Core Data Persistent Store

Episode 1

Three Strategies

Seeding an application with data can be helpful for a wide range of reasons, including unit and performance testing. As a developer, seeding an application is simply convenient during development. You want to see and experience what the application feels like with data in it, without having to enter that data in by hand. How does the application perform with hundreds or thousands of records? What is the user experience like?

Episode 2

Hard-Coding Seed Data

Seeding a Core Data persistent store with hard-coded seed data is fast and easy. The application we'll be seeding with data in this episode is Notes, the application we build in Core Data Fundamentals. Download the starter project of this episode if you'd like to follow along.

Episode 3

Seeding Data Asynchronously

We successfully seeded the Core Data persistent store with hard-coded seed data in the previous episode. While the implementation works fine, it isn't perfect. Seeding the persistent store takes place on the main thread. We invoke the seed() method in the viewDidLoad() method of the NotesViewController class and we insert the managed objects into the main managed object context of the Core Data manager.

Episode 4

Avoiding Duplicates

Every time we launch Notes, the persistent store is seeded with data. That's not what we want as it results in duplicates. In this episode, you learn how to easily avoid duplicates and how to start with a clean slate if you decide you no longer need seed data.