Reputation: 19
// Errors on [indexPath!] and [newIndexPath!] ---- the message "Cannot convert value of type 'NSIndexPath?' to expected element type 'Array<IndexPath>.ArrayLiteralElement' (aka 'IndexPath')"
func controller(controller:
NSFetchedResultsController<NSFetchRequestResult>, didChangeObject
anObject: AnyObject, atIndexPath indexPath: NSIndexPath?,
forChangeType type: NSFetchedResultsChangeType, newIndexPath:
NSIndexPath?) {
switch(type) {
case .insert:
self.heroTableView.insertRowsAtIndexPaths([newIndexPath!],
withRowAnimation: .fade)
case .delete:
self.heroTableView.deleteRowsAtIndexPaths([indexPath!],
withRowAnimation: .fade)
default:
()
}
}
Upvotes: 0
Views: 71
Reputation: 19
// Thank you, Willeke. // I post this for those who will meet the same errors.
func controller(controller:
NSFetchedResultsController<NSFetchRequestResult>, didChangeObject
anObject: AnyObject, atIndexPath indexPath: IndexPath?,
forChangeType type: NSFetchedResultsChangeType, newIndexPath:
IndexPath?) {
switch(type) {
case .insert:
self.heroTableView.insertRows(at: [newIndexPath!], with: .fade)
case .delete:
self.heroTableView.deleteRows(at: [indexPath!], with: .fade)
default:
()
}
}
Upvotes: 1