<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTableViewDelegate/tableView(_:shouldSelectRow:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTableViewDelegate(im)tableView:shouldSelectRow:"
  },
  "title" : "tableView(_:shouldSelectRow:)"
}
-->

# tableView(_:shouldSelectRow:)

Asks the delegate if the table view should allow selection of the specified row.

```
@MainActor optional func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool
```

## Parameters

`tableView`

The table view that sent the message.

`row`

The row index.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> to permit selection of the row, <doc://com.apple.documentation/documentation/Swift/false> to deny selection.

## Discussion

The delegate can implement this method to disallow selection of particular rows.

For better performance and finer-grain control over the selection, use [`tableView(_:selectionIndexesForProposedSelection:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:selectionIndexesForProposedSelection:)).

---

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)