I am trying to update my array data and reload the tableview once user click on a cell, however, it takes three hits till the tableview reload a specific row that was selected. This problem only occur when I use (tableview.reloadRows()) but if I use (tableview.reloadData()) everything is working fine with just a single click but I don't want to reload the entire tableview. Can someone please tell me what I did wrong?
Code Block extension ViewController: UITableViewDataSource, UITableViewDelegate { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return dummyData.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let todoCell = tableView.dequeueReusableCell(withIdentifier: "todoCell") as! TodoTableViewCell todoCell.dataLabel.text = dummyData[indexPath.row].item if (dummyData[indexPath.row].done == false) { todoCell.dataLabel.hideStrikeTextLayer() }else{ todoCell.dataLabel.strikeThroughText() } todoCell.delegate = self return todoCell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let index = IndexPath(row: indexPath.row, section: 0) if dummyData[indexPath.row].done == false { dummyData[indexPath.row].done = true todoTableView.reloadRows(at: [index], with: .none) }else { dummyData[indexPath.row].done = false todoTableView.reloadRows(at: [index], with: .none) } } }