I can not understand why I can not toggle a selected table row. I am successfully setting the accessoryType in didSelectRowAt. But I can not seem to set the accessoryType to none in didDeselectRowAt.
my data:
serviceItems = ["Heater", "Air Conditioner", "Boiler", "Heat Pump"]
here are my tableview overrides:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.accessoryType = .checkmark
let serviceItem = serviceItems[indexPath.row] as! String
cell.textLabel?.text = serviceItem
}
// does not remove checkmark
// does not change textLabel to "test"
// DOES print "DESELECTING" (so I know its getting called)
override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.accessoryType = .none
cell.textLabel?.text = "test"
print("DESELECTING")
}