> For the complete documentation index, see [llms.txt](https://pakornpat.gitbook.io/ios-app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pakornpat.gitbook.io/ios-app/v1/delete-todo-item.md).

# Delete todo item

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

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

```swift
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 ได้

![](/files/-LGzbBg9OW_k6snNmpD2)
