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

# NSTableViewDelegate

A set of optional methods you implement in a table view delegate to customize the behavior of the table view.

```
protocol NSTableViewDelegate : NSControlTextEditingDelegate
```

## Overview

Using a table view delegate allows you to customize a table view’s behavior without creating a table view subclass. A table view delegate provides views for table rows and columns, and supports functionality such as column reordering and resizing and row selection. To learn more about table views, see [`NSTableView`](/documentation/AppKit/NSTableView).

## Topics

### Providing views for rows and columns

[`tableView(_:viewFor:row:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:viewFor:row:))

Asks the delegate for a view to display the specified row and column.

[`tableView(_:rowViewForRow:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:rowViewForRow:))

Asks the delegate for a view to display the specified row.

### Notification of row views being added or removed

[`tableView(_:didAdd:forRow:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:didAdd:forRow:))

Tells the delegate that a row view was added at the specified row.

[`tableView(_:didRemove:forRow:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:didRemove:forRow:))

Tells the delegate that a row view was removed from the table at the specified row.

### Grouping rows

[`tableView(_:isGroupRow:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:isGroupRow:))

Returns whether the specified row is a group row.

### Providing cells for rows and columns

[`tableView(_:willDisplayCell:for:row:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:willDisplayCell:for:row:))

Tells the delegate that the table view will display the specified cell at the specified row and column.

[`tableView(_:dataCellFor:row:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:dataCellFor:row:))

Asks the delegate for a custom data cell for the specified row and column.

[`tableView(_:shouldShowCellExpansionFor:row:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:shouldShowCellExpansionFor:row:))

Asks the delegate if an expansion tooltip should be displayed for a specific row and column.

[`tableView(_:toolTipFor:rect:tableColumn:row:mouseLocation:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:toolTipFor:rect:tableColumn:row:mouseLocation:))

Asks the delegate for a string to display in a tooltip for the specified cell in the column and row.

### Editing cells

[`tableView(_:shouldEdit:row:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:shouldEdit:row:))

Asks the delegate if the cell at the specified row and column can be edited.

### Setting row and column size

[`tableView(_:heightOfRow:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:heightOfRow:))

Asks the delegate for the height of the specified row.

[`tableView(_:sizeToFitWidthOfColumn:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:sizeToFitWidthOfColumn:))

Asks the delegate to provide custom sizing behavior when a column’s resize divider is double clicked.

### Selecting rows

[`selectionShouldChange(in:)`](/documentation/AppKit/NSTableViewDelegate/selectionShouldChange(in:))

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

[`tableView(_:shouldSelectRow:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:shouldSelectRow:))

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

[`tableView(_:selectionIndexesForProposedSelection:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:selectionIndexesForProposedSelection:))

Asks the delegate to accept or reject the proposed selection.

[`tableView(_:shouldSelect:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:shouldSelect:))

Asks the delegate whether the specified table column can be selected.

[`tableViewSelectionIsChanging(_:)`](/documentation/AppKit/NSTableViewDelegate/tableViewSelectionIsChanging(_:))

Tells the delegate that the table view’s selection is in the process of changing.

[`tableViewSelectionDidChange(_:)`](/documentation/AppKit/NSTableViewDelegate/tableViewSelectionDidChange(_:))

Tells the delegate that the table view’s selection has changed.

[`tableView(_:shouldTypeSelectFor:withCurrentSearch:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:shouldTypeSelectFor:withCurrentSearch:))

Asks the delegate to allow or deny type select for the specified event and current search string.

[`tableView(_:typeSelectStringFor:row:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:typeSelectStringFor:row:))

Asks the delegate to provide an alternative text value used for type selection for the specified row and column.

[`tableView(_:nextTypeSelectMatchFromRow:toRow:for:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:nextTypeSelectMatchFromRow:toRow:for:))

Asks the delegate for the row within the specified search range that matches the specified string.

### Moving and resizing columns

[`tableView(_:shouldReorderColumn:toColumn:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:shouldReorderColumn:toColumn:))

Asks the delegate to allow or prohibit the specified column to be dragged to a new location.

[`tableView(_:didDrag:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:didDrag:))

Tells the delegate that the specified table column was dragged.

[`tableViewColumnDidMove(_:)`](/documentation/AppKit/NSTableViewDelegate/tableViewColumnDidMove(_:))

Tells the delegate that a table column was moved by user action.

[`tableViewColumnDidResize(_:)`](/documentation/AppKit/NSTableViewDelegate/tableViewColumnDidResize(_:))

Tells the delegate that a table column was resized.

### Responding to mouse events

[`tableView(_:didClick:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:didClick:))

Tells the delegate that the mouse button was clicked in the specified table column, but the column was not dragged.

[`tableView(_:mouseDownInHeaderOf:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:mouseDownInHeaderOf:))

Tells the delegate that the mouse button was clicked in the specified table column’s header.

[`tableView(_:shouldTrackCell:for:row:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:shouldTrackCell:for:row:))

Asks the delegate whether the specified cell should be tracked.

### Enabling table row actions

[`tableView(_:rowActionsForRow:edge:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:rowActionsForRow:edge:))

Asks the delegate to provide an array of row actions to be attached to the specified edge of a table row and displayed when the user swipes horizontally across the row.

### Showing and hiding columns

[`tableView(_:userCanChangeVisibilityOf:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:userCanChangeVisibilityOf:))

Asks the delegate to verify that the user can change the given column’s visibility.

[`tableView(_:userDidChangeVisibilityOf:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:userDidChangeVisibilityOf:))

Tells the delegate that the user changed the visibility of one or more table columns.



---

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)