extension ViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
// 내부 데이터와 연동한 로직 구현 ex
if editingStyle == .delete {
if indexPath.sction == 0 {
data.remove(at: indexPath.row)
} else {
testAppend.remove(at: indexPath.row)
}
}
tableView.reloadData()
}
}
- 위와 다르게, edit 모드로 들어가서 삭제, 일괄 선택 및 삭제로 구현, custom swipe 버튼 구현 등 여러 방법으로 삭제 코드를 작성할 수 있다.
- [[1. UITableView]]
- [[15. 스와이프 버튼 커스텀]]
- #IOS/UITableView/Delegate