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.
Subscribe to Cocoacasts Plus to watch this episode.
Seeding a Core Data Persistent Store
Seeding Data Asynchronously
by Bart Jacobs in Core Data
Swift 4
Xcode 9
iOS 11
Seeding a Core Data Persistent Store
-
05:11
-
09:52
-
3 Seeding Data Asynchronously
08:34
-
08:12
-
5 Loading Seed Data From a File
08:21