*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).
[func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? {
guard orientation == .right else { return nil }
let deleteAction = SwipeAction(style: .destructive, title: "Delete") { action, indexPath in
// handle action by updating model with deletion
self.com.showProgress()
let dict=self.arrayPendings[indexPath.row] as! [String:Any]
if let reid=dict["RequestId"] as? Int
{
self.selectedReqID=String(reid)
}
self.deleteLeave(){ (status) in
if(status)
{
var options = SwipeTableOptions()
options.expansionStyle = .destructive(automaticallyDelete: false)
let delete = SwipeAction(style: .destructive, title: nil) { action, indexPath in
self.com.removeProgress()
self.arrayPendings.remove(at: indexPath.row)
self.tblPendingLeaves.beginUpdates()
self.tblPendingLeaves.insertRows(at: [IndexPath(row: 0, section: 1)], with: .automatic)
action.fulfill(with: .delete)
self.tblPendingLeaves.endUpdates()
}
}
}
}
// customize the action appearance
deleteAction.image = UIImage(named: "Delete")
return [deleteAction]
}
Please help me.