Highlight tableview cell when tapped and unhighlight when alert controller action buttons are pressed
<p>I like to highlight row in tableview cell when user touches the cell in <code>blue</code>, and then when user selects the action button, I want it to change it to <code>gray</code> color </p>

<pre><code>   func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    var newCell = tableView.cellForRow(at: indexPath)!
    newCell.backgroundColor = UIColor.blue

    let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

    let okButton = UIAlertAction(title: "Ok", style: .default, handler: { (action) -&gt; Void in
        print("Ok button tapped")
        var newCell = tableView.cellForRow(at: indexPath)!
        newCell.backgroundColor = UIColor.gray
    })

    let cancelButton = UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -&gt; Void in
        print("Cancel button tapped")
        var newCell = tableView.cellForRow(at: indexPath)!
        newCell.backgroundColor = UIColor.gray
    })

    alertController.addAction(okButton)
    alertController.addAction(cancelButton)

    present(alertController, animated: true, completion: nil)
}

func tableView(_ tableView: UITableView, didhighlightRowAt indexPath: IndexPath) {
    var newCell = tableView.cellForRow(at: indexPath)!
    newCell.backgroundColor = UIColor.clear
}
</code></pre>

<p>I did this and it highlights the cell in <code>white</code> color and after action button is tapped, it still stays <code>white</code> but when I tap another cell, the previous cell turns and remains <code>gray</code></p>