Apple Developer Documentation

Methods for managing selections, configuring section headers and footers, deleting and reordering cells, and performing other actions in a table view. selection들에 대한 관리, 섹션 헤더와 푸터 구성, 셀들의 삭제와 재정렬, 테이블뷰에서 기타 액션 수행

overview

DataSource와는 다르게 필수 구현 메서드는 없다.

DidSelectRowAt

// 셀이 선택되었을 때,
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    print(itemArray[indexPath.row])
    //선택된 셀의 악세사리 타입이 어떤 종류인가??
    let type = tableView.cellForRow(at: indexPath)?.accessoryType
    
    if type == .checkmark {
        tableView.cellForRow(at: indexPath)?.accessoryType = .none
    } else {
        tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark
    }
    //선택된 셀을 해제
    tableView.deselectRow(at: indexPath, animated: true)
}

accessory type

Apple Developer Documentation