It seems there is something wrong with the code.
it’s unnecessary to change code in SegueListToDetail block but should change code in SegueListToDetailAdd block
else if segue.identifier == “SegueListToDetailAdd” {
I believe you’re referring to NSPersistentContainer as NSPersistantCoordinator has been around for a while?
NSPersistentContainer is just a new class that simplifies creating a new Core Data stack. This project already makes use of it if you look at CoreDataStack.swift.
With NSPersistentContainer you can still create child context or sibling context like you always have.
Susan, you are correct. This is actually not the full chapter. In the book version there is a challenge at the very end that ask the student to do exactly what you said.
With your newfound knowledge, try to update SegueListToDetailAdd to use a child context when adding a new journal entry.
I was just wandering, you set child context concurrency type to mainQueueConcurrencyType, because it was fast operation, so no point in setting it in background, right? Otherwise you would use PrivateQueueConcurrencyType, with childContext.perform()?
I used MainQueueConcurrencyType, the default type, to specify that the context will be associated with the main queue. This type is what the main context (coreDataStack.mainContext) uses. Any UI operation, such as creating the fetched results controller for the table view, must use a context of this type.
Any time you’re interacting with UIKit you should stick to the main queue.
As far as setting up your default database (the data the appears the first time you run)… It’s not necessary to copy the shm database file, right? That’s just a temporary file.