Delete todo item
เพิ่มผิดอยากลบทำยังไง
เพิ่ม TableViewDataSource ฟังก์ชั่นนี้ เพื่อให้ TableView รู้เป็นอันเสร็จ
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
todo.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .automatic)
}
}
เราจะสามารถปัดแล้ว Delete ได้

Last updated