Mobile App Development for iOS
Notes Topics Weekly Resources Graded work Professor Code examplesIn our discussion about fetched results controller, we learned that “monitor changes to the data objects, and report on those changes, so that the hosting controller can update the user interface.”
This works like magic. Changes - adds, edits, deletes - are made via the context (and the data store), and the table view is updated, with animation, because its content is managed by the fetched results controller.
Here is a short video clip (which you can view in the Safari browser) that shows this in action:
Several design and coding tasks are required, and learning what and why takes several hours. In the past, we have spent hours in class on this topic, and some students have spent hours (or days) implementing the solution.
As a result, we’re not going to do this.
(Inspired by the famous Star Wars movie quote, “Use the Force, Luke”).
Here are the pieces involved. Open and study any project that was generated by TemplateCDv2
.
Core Data technologies are used for the backing store.
The table view controller conforms to the NSFetchedResultsControllerDelegate
.
The table view data source is a fetched results controller (frc).
The table view supports editing (see line 42, and line 78, and line 88, and line 130).
Table view updates, with animation, but without reloading the entire table view, is handled by methods in the ListBaseCD+FRCDelegate.swift extension.
Does this work with…
Add, using a modal scene?
Yes.
Add, where the data comes from the network or whatever?
Yes.
Edit, using a modal scene?
Yes.