<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITableViewDelegate/tableView(_:willSelectRowAt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITableViewDelegate(im)tableView:willSelectRowAtIndexPath:"
  },
  "title" : "tableView(_:willSelectRowAt:)"
}
-->

# tableView(_:willSelectRowAt:)

Tells the delegate a row is about to be selected.

```
optional func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath?
```

## Parameters

`tableView`

A table view informing the delegate about the impending selection.

`indexPath`

An index path locating the row in `tableView`.

## Return Value

An index path that confirms or alters the selected row. Return an <doc://com.apple.documentation/documentation/Foundation/IndexPath> (Swift) or <doc://com.apple.documentation/documentation/Foundation/NSIndexPath> (Objective-C) other than `indexPath` if you want another cell to be selected. Return `nil` if you don’t want the row selected.

## Discussion

The system calls this method after a user has lifted their finger; the row is highlighted on the initial touch, but only selected when the touch withdraws. You can use [`UITableViewCell.SelectionStyle.none`](/documentation/UIKit/UITableViewCell/SelectionStyle-swift.enum/none) to disable the appearance of the cell highlight on the initial touch. The system doesn’t call this method if the rows in the table aren’t selectable. See [Handling row selection in a table view](/documentation/UIKit/handling-row-selection-in-a-table-view) for more information on controlling table row selection behavior.

## See Also

[`-  tableView:shouldIndentWhileEditingRowAtIndexPath:`](/documentation/UIKit/UITableViewDelegate/tableView(_:shouldIndentWhileEditingRowAt:))

Asks the delegate whether the background of the specified row should be indented while the table view is in editing mode.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)