Database Reference
In-Depth Information
pad. As the user edits the journal entry, you update the attributes of the managed
object. Once the changes are complete, you can either save them or throw them
away, depending on the user's desire.
You can think of child managed object contexts the same way: as temporary
scratch pads that you can either save, sending the changes to the parent context,
or completely throw away.
But what is a child context, technically?
All managed object contexts have a parent store from which you can retrieve and
change data in the form of managed objects, such as the JournalEntry objects in
this project. Typically, the parent store is a persistent store coordinator, which is
the case for the main context provided by the CoreDataStack class. Alternatively,
you can set the parent store for a given context to another managed object
context, making it a child context.
When you save a child context, the changes only go to the parent context. Changes
to the parent context are not sent to the persistent store coordinator until the
parent context is also saved.
Before you jump in and add a child context, you need to understand how the
current viewing and editing operation works.
Viewing and editing
The first part of the operation requires segueing from the main list view to the
journal detail view. Open JournalListViewController.swift and find
prepareForSegue :
// 1
if segue. identifier == "SegueListToDetail" {
// 2
let indexPath = tableView . indexPathForSelectedRow ()
Search WWH ::




Custom Search