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

# selectionShouldChange(in:)

Asks the delegate if the user is allowed to change the selection.

```
@MainActor optional func selectionShouldChange(in tableView: NSTableView) -> Bool
```

## Parameters

`tableView`

The table view that sent the message.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> to allow the table view to change its selection (typically a row being edited), <doc://com.apple.documentation/documentation/Swift/false> to deny selection change.

## Discussion

The user can select and edit different cells within the same row, but can’t select another row unless the delegate approves. The delegate can implement this method for complex validation of edited rows based on the values of any of their cells.

---

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)