I am not sure what is wrong with the code below. All I'm doing is getting all the rows in the table and marking them as selected, and if they're already selected, I'm deselecting them. Whenever I try this, some of the row index paths are incorrect. There are always a few index paths that are missed every time. What am I doing wrong?
let visibleRows = self.tableView.indexPathsForVisibleRows
for row in visibleRows! {
if(self.sections[row.section].files[row.row].type != "cloud"){
let cell = self.tableView.cellForRowAtIndexPath(row)
cell?.setSelected(action, animated: true)
tableView.selectRowAtIndexPath(row, animated: true, scrollPosition: UITableViewScrollPosition.Top)
if(action == true){
cell?.accessoryType = .Checkmark
} else {
cell?.accessoryType = .None
NSNotificationCenter.defaultCenter().postNotificationName("disableOptions", object: nil)
}
}
}