I have a UITableViewController with NSFetchedResultsController connected to it.
It's implemented pretty closely to Apple guide here:
func initializeFetchedResultsController() {
let request = NSFetchRequest(entityName: "Person")
let departmentSort = NSSortDescriptor(key: "department.name", ascending: true)
let lastNameSort = NSSortDescriptor(key: "lastName", ascending: true)
request.sortDescriptors = [departmentSort, lastNameSort]
let moc = dataController.managedObjectContext
fetchedResultsController = NSFetchedResultsController(fetchRequest: request, managedObjectContext: moc, sectionNameKeyPath: "department.name", cacheName: nil)
fetchedResultsController.delegate = self
do {
try fetchedResultsController.performFetch()
} catch {
fatalError("Failed to initialize FetchedResultsController: \(error)")
}
}
I have custom cells for section headers. In the section header I'm showing department name and number of employees within a department (which is a stored property).
The problem I have is that when number of employees is updated, didChangeSection is never called.
Should I monitor didChangeObject and reload the section or is there a better way?