I have an app that sections and it lets user add items to a certain section. For example, the use can add "wash car" to the Monday section. I am having trouble getting the delete function to work, so that the user can remove the item if they by chance added it or have completed the item. So far what I have give me either a "could not cast value of type" error or "index out of range" error. I'm looking to see if this is the correct way of removing items or if there is different way.
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == UITableViewCellEditingStyle.delete {
//list.remove(at: indexPath.row)
list.remove(at: [[indexPath.row]] as Any as! Int)
UserDefaults.standard.set(list, forKey: "list")
tableView.reloadData()
}
}