我试图以这种方式从UITableView
删除一行:
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
let itemToDelete: Device = fetchedResultsController.objectAtIndexPath(indexPath) as! Device
(UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext?.deleteObject(itemToDelete)
self.fetchedResultsController.performFetch(nil)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
}
}
当我跑步时,我收到此错误:
Invalid update: invalid number of sections. The number of sections contained in the table view after the update (0) must be equal to the number of sections contained in the table view before the update (1), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).