데이터를 삭제
한 뒤, 테이블뷰 아이템 삭제
순서로 진행해야한다.1. 데이터 업데이트
2. 테이블뷰 업데이트
override func tableView(_ tableView: UITalbeView, commit editingSytle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
let target = contents[indexPath.row]
if removeItem(at: target.url) {
//순서 바뀌면 안됨
contents.remove(at: indexPath.row)
//해당 메소드 호출 시 데이터 수 일치하지 않으면 크래시 발생
tableView.deleteRows(at: [indexPath], with: .automatic)
}
}
}