func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: Ind...
func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
switch type {
case .delete:
tableView.deleteRows(at: [indexPath!], with: .automatic)
case .insert:
tableView.insertRows(at: [indexPath!], with: .automatic)
case .update:
tableView.reloadRows(at: [indexPath!], with: .automatic)
default:
tableView.reloadData()
}
if let objects = controller.fetchedObjects{
area = objects as! [AreaMO]
}
}
报错 indexPath为nil