Question: I'm trying to pre select a table row when the view load, however i have tried several methods, but none seem to work. At first i've set following two methods in order to define the textColor changes when a row is selected and deselected

```
open func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
    let cell = menuCells[indexPath.row]

    cell.textLabel?.textColor = UIColor.white.withAlphaComponent(0.4)
}

open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let cell = menuCells[indexPath.row]

    cell.textLabel?.textColor = UIColor.white.withAlphaComponent(1.0)

    UIApplication.shared.sendAction(cell.menuAction, to: cell.menuTarget, from: cell, for: nil)
}

```

Then i've tried to do following things to preselect a row but it does not seem to change the textColor with alpha to 1.0

```
open func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {

    if indexPath.row == 0 {
        cell.setSelected(true, animated: false)
    }
}

menuView.selectRow(at: IndexPath(row: 0, section: 0), animated: false, scrollPosition: UITableViewScrollPosition.none)

```

Answer: 
Is this what you're after?

```
override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)

        let iPath = NSIndexPath(forRow: 0, inSection: 0)
        tableView.selectRowAtIndexPath(iPath, animated: true, scrollPosition: .Top )
    }

```
Remember that `tableView(_:didSelectRowAt:)` is part of a delegate protocol designed to handle user interactions with the `UITableView` instance. It is therefore called in response to user interaction, not programatic changes.

To resolve this, move your appearance changes into a separate function called something like `applyAppearanceSelected` and call this when you make programatic changes, and also call it from `tableView(_:didSelectRowAt:)` to handle user-initiated changes. I would not recommend calling `tableView(_:didSelectRowAt:)` directly yourself, because you might want to add other code there that only applies when the *user* selects a cell.