I write custom jabber client in iphone.
I use xmppframework as engine.
And I have UITableViewController with NSMutableArray for repesent contact list.
<
A lot of these answers are basically using hacks to re-select the row that was previously highlighted by finding out what the previously selected row was from the table view which seems like a bad way to go about it, because usually when your tableview reloads, there is a change in the data that is populating the tableview.
So rather base you re-selection of the row based on your data
let data = ["some", "array", "of", "data"]
let selected = "of" // this should be populated from didSelectRowAt indexPath:
tableView.reloadData()
if let index = data.firstIndex(of: selected) {
tableView.selectRow(at: IndexPath(row: index, section: 0), animated: false, scrollPosition: .none) // the "of" row should now be highlighted, regardless if the data changed order
}