I'm working on a Core Data App. I'm using Xcode 8.2.
Not all the change methods of the NSFetchedResultsControllerDelegate are not being called for changing objects. (i.e. when I insert a new object into the context)
Does anyone know why this might be? To verify I haven't made a typo, I even copy-pasted that from a typical Master-Detail Application Template.
I'm hoping to animate the tableview rows.
// works
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
// DOESN'T WORK!!
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>,
didChange anObject: Any,
at indexPath: IndexPath?,
for type: NSFetchedResultsChangeType,
newIndexPath: IndexPath?)
// WORKS
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
I figured out what the problem was. I'm using a baseclass (say) MyFetchedResultsControllerTableViewDataSource
, where a NSFetchedResultsController is instantiated and who's delegate is specified to 'self'.
The problem is that the baseclass wasn't implementing those methods where subclasses were. I had to make a default implementation in the baseclass then override, then it worked.
This is different to objective-C, which would check at runtime for optional method implementations with 'respondsToSelector'...