---
title: "selectionShouldChange(in:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstableviewdelegate/selectionshouldchange(in:)"
---

# selectionShouldChange(in:)

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

## Declaration

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

## Parameters

- `tableView`: The table view that sent the message.

## Return Value

Return Value true to allow the table view to change its selection (typically a row being edited), false to deny selection change.

## Discussion

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.

## See Also

### Selecting rows

- [tableView(_:shouldSelectRow:)](appkit/nstableviewdelegate/tableview(_:shouldselectrow:).md)
- [tableView(_:selectionIndexesForProposedSelection:)](appkit/nstableviewdelegate/tableview(_:selectionindexesforproposedselection:).md)
- [tableView(_:shouldSelect:)](appkit/nstableviewdelegate/tableview(_:shouldselect:).md)
- [tableViewSelectionIsChanging(_:)](appkit/nstableviewdelegate/tableviewselectionischanging(_:).md)
- [tableViewSelectionDidChange(_:)](appkit/nstableviewdelegate/tableviewselectiondidchange(_:).md)
- [tableView(_:shouldTypeSelectFor:withCurrentSearch:)](appkit/nstableviewdelegate/tableview(_:shouldtypeselectfor:withcurrentsearch:).md)
- [tableView(_:typeSelectStringFor:row:)](appkit/nstableviewdelegate/tableview(_:typeselectstringfor:row:).md)
- [tableView(_:nextTypeSelectMatchFromRow:toRow:for:)](appkit/nstableviewdelegate/tableview(_:nexttypeselectmatchfromrow:torow:for:).md)
