-1
我有下面的代码,我尝试删除行。当行不节最后一切正常,但是当它是最后一个部分 - 应用程序的崩溃任务:删除部分:)
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
if let item = shopList.getItem(index: indexPath) {
shopTableView.beginUpdates()
let indexSet = NSMutableIndexSet()
indexSet.add(indexPath.section - 1)
shopTableView.deleteRows(at: [indexPath], with: .fade)
//shopTableView.deleteSections(indexSet as IndexSet, with: UITableViewRowAnimation.automatic)
shopList.remove(item: item)
shopTableView.endUpdates()
}
}
}
我有错误
“NSInternalInconsistencyException”,理由是:“无效的更新:无效>部分的数量。更新(1)后,表视图>中包含的部分数量必须等于更新前的表格视图中包含的部分数量(2),加上或减去>插入或删除的部分数量(0插入,0删除)。'
有没有标准的方法来做到这一点?