Skip to content

Commit

Permalink
Avoid crash when deleting the last downloaded of a course
Browse files Browse the repository at this point in the history
  • Loading branch information
mathebox committed Oct 26, 2021
1 parent c307b8f commit 2b4e2a7
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ extension DownloadedContentListViewController { // Table view data source
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return self.courseDownloads[section].title
// When deleting the last item from a course, this method is called. So we play it safe and don't risk an 'Index out of range' error.
return self.courseDownloads[safe: section]?.title
}

override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
Expand Down

0 comments on commit 2b4e2a7

Please sign in to comment.