Skip to content

Commit

Permalink
Reload table when the fetched results change.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZevEisenberg committed Aug 4, 2019
1 parent d57e61c commit 9a3632b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CoreDataDemo/SessionsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SessionsViewController: UITableViewController {
sectionNameKeyPath: nil, // not using sections
cacheName: nil // no need for caching
)
fetchedResultsController.delegate = self

do {
try fetchedResultsController.performFetch()
Expand Down Expand Up @@ -67,3 +68,11 @@ class SessionsViewController: UITableViewController {
}

}

extension SessionsViewController: NSFetchedResultsControllerDelegate {

func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
tableView.reloadData()
}

}

0 comments on commit 9a3632b

Please sign in to comment.