I have a VERY annoying problem.
I have a tableView with more or less than 50 cells displaying some parameters that I can select the ones I want. I read in the Apple documentation that, by default, cells are reused when they are not displayed. In this case, if I select the first cell, every 6 cells 1 will be marked, that is, if I select the first 6 cells, ALL cells in the table will be marked!
There are several options in my table view. The selection is as follows:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCellAccessoryType.checkmark
}
How can i solve this? I know that you have such "prepareForReuse ()" for a subclass, will this be a solution? If so, can you give me an example of how you will do this?
source
share