Skip to content

Commit 9a3632b

Browse files
committed
Reload table when the fetched results change.
1 parent d57e61c commit 9a3632b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

CoreDataDemo/SessionsViewController.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class SessionsViewController: UITableViewController {
3535
sectionNameKeyPath: nil, // not using sections
3636
cacheName: nil // no need for caching
3737
)
38+
fetchedResultsController.delegate = self
3839

3940
do {
4041
try fetchedResultsController.performFetch()
@@ -67,3 +68,11 @@ class SessionsViewController: UITableViewController {
6768
}
6869

6970
}
71+
72+
extension SessionsViewController: NSFetchedResultsControllerDelegate {
73+
74+
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
75+
tableView.reloadData()
76+
}
77+
78+
}

0 commit comments

Comments
 (0)