didDeselectRowAtIndexPath indexPath é nulo
Eu tenho um TableViewController que implementa os métodos TableViewDelegate:
public override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath) as! ParticipantesSearchTableViewCell
cell.viewModel?.active = true
}
public override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath) as! ParticipantesSearchTableViewCell
cell.selectedStateImageView.hidden = true
cell.viewModel?.active = false
}
Observe que nunca removo nem defino meu tableView.editing como true. Também meunumberOfRowsInSection
O método nunca muda.
Se eu definir meu tableView comotableView.allowsSingleSelection = true
Posso selecionar e desmarcar as células muito bem e os métodos acima são acionados conforme o aspecto. No entanto, quando eu rolar na minha tableView e selecionar uma nova célula, o método didDeselectRowAtIndexPath falha emlet cell = tableView.cellForRowAtIndexPath(indexPath) as! ParticipantesSearchTableViewCell
Neste ponto, depureitableView.indexPathForSelectedRow
e retorna nulo.
Alguma idéia do que estou implementando errado aqui ou se isso é um bug? Porque eu tento usar a mesma tabela comtableView.allowsMultipleSelection = true
e posso selecionar, desmarcar e rolar muito bem.