let indexPaths = (0..<array.count - 1).map { i in
return IndexPath(item: i, section: section)
}
tableView.beginUpdates()
if hidden[section] {
array.remove(at: IndexPath(item: item, section: section).row)
tableView.deleteRows(at: indexPaths, with: .fade)
} else {
tableView.insertRows(at: indexPaths, with: .fade)
}
tableView.endUpdates()
I want to delete all cells of a section in UITableView when a header of that section is tapped. However, it does not seem to work correctly.
The error says that "Cannot convert value of type CountableRange<Int> to expected argument Int".
What is the correct way to delete all cells?
removeAll()) in the data source array then calldeleteSections()on the tableView passing the appropriate section.