I am trying the change the title of UITableViewRowAction each time the user press on it like complete/incomplete, the code I wrote puts the checkmark but does not change the title, so the checkmark can not be removed:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let completeAction = UITableViewRowAction(style: .normal, title: "Complete", handler: { (action, indexPath) in
if action.title == "Complete"{
action.title = "Incomplete"
cell?.accessoryType = UITableViewCellAccessoryType.checkmark
}
else{
cell?.accessoryType = UITableViewCellAccessoryType.none
action.title = "Complete"
}
tableView.setEditing(false, animated: true)
})
completeAction.backgroundColor = .blue
return [completeAction]
}
Any advice?