// 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:
()
}
}
// Thank you, Willeke. // I post this for those who will meet the same errors. func controller(controller:
NSFetchedResultsController, 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:
()
} }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.