Delete todo item

เพิ่มผิดอยากลบทำยังไง

เพิ่ม TableViewDataSource ฟังก์ชั่นนี้ เพื่อให้ TableView รู้เป็นอันเสร็จ

ViewController.swift
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        todo.remove(at: indexPath.row)
        tableView.deleteRows(at: [indexPath], with: .automatic)
    }
}

เราจะสามารถปัดแล้ว Delete ได้

Last updated