---
title: NSTableView
framework: appkit
role: symbol
role_heading: Class
path: appkit/nstableview
---

# NSTableView

A set of related records, displayed in rows that represent individual records and columns that represent the attributes of those records.

## Declaration

```swift
class NSTableView
```

## Overview

Overview Table views are displayed in scroll views. Beginning with macOS v10.7, you can use NSView objects (most commonly customized NSTableCellView objects) instead of cells for specifying rows and columns. You can still use NSCell objects for each row and column item if you prefer. A table view does not store its own data; it retrieves data values as needed from a data source to which it has a weak reference. You should not, therefore, directly set data values programmatically in the table view; instead, modify the values in the data source and allow the changes to be reflected in the table view. To learn about the methods that an NSTableView object uses to provide and access the contents of its data source object, see NSTableViewDataSource. To customize a table view’s behavior without subclassing NSTableView, use the methods defined by the NSTableViewDelegate protocol. For example, the delegate supports table column management, type-to-select functionality, row selection and editing, custom tracking, and custom views for individual columns and rows. To learn more about the table view delegate, see NSTableViewDelegate. important: It’s possible that your data source methods for populating the table view may be called before awakeFromNib() is called if the data source is specified in Interface Builder. You should defend against this by having the data source’s numberOfRows(in:) method return 0 for the number of rows when the data source has not yet been configured. In awakeFromNib(), when the data source is initialized you should always call reloadData on the table view. Subclassing Subclassing NSTableView is usually not necessary. Instead, you customize the table view using a delegate object (an object conforming to the NSTableViewDelegate protocol) and a data source object (conforming to the NSTableViewDataSource protocol), or by subclassing one of the following subcomponents: cells (when using NSCell-based table views), the row cell view or the row view (when using NSView-based table views), the table column class, or table column header classes. Enabling the Table View Use the isEnabled property to enable or disable the table view, which the view inherits from NSControl. This property affects the visual appearance of the table view differently depending on whether you use a view- or a cell-based table view. When you change the property’s value for a cell-based table view, the system manages the visual appearance of that table view’s rows, and updates them to a state that reflects the value. Because view-based table views permit complex items in their cells, it’s the developer’s responsibility to update each cell’s appearance as appropriate.

## Topics

### Creating a Table

- [init(coder:)](appkit/nstableview/init(coder:).md)
- [init(frame:)](appkit/nstableview/init(frame:).md)

### Managing the Table’s Data

- [dataSource](appkit/nstableview/datasource.md)
- [usesStaticContents](appkit/nstableview/usesstaticcontents.md)
- [reloadData()](appkit/nstableview/reloaddata().md)
- [reloadData(forRowIndexes:columnIndexes:)](appkit/nstableview/reloaddata(forrowindexes:columnindexes:).md)

### Creating Views to Display

- [makeView(withIdentifier:owner:)](appkit/nstableview/makeview(withidentifier:owner:).md)
- [rowView(atRow:makeIfNecessary:)](appkit/nstableview/rowview(atrow:makeifnecessary:).md)
- [view(atColumn:row:makeIfNecessary:)](appkit/nstableview/view(atcolumn:row:makeifnecessary:).md)
- [NSUserInterfaceItemIdentifier](appkit/nsuserinterfaceitemidentifier.md)

### Updating the Table View Arrangement

- [beginUpdates()](appkit/nstableview/beginupdates().md)
- [endUpdates()](appkit/nstableview/endupdates().md)
- [moveRow(at:to:)](appkit/nstableview/moverow(at:to:).md)
- [insertRows(at:withAnimation:)](appkit/nstableview/insertrows(at:withanimation:).md)
- [removeRows(at:withAnimation:)](appkit/nstableview/removerows(at:withanimation:).md)
- [row(for:)](appkit/nstableview/row(for:).md)
- [column(for:)](appkit/nstableview/column(for:).md)

### NSView-Based Table Nib File Registration

- [register(_:forIdentifier:)](appkit/nstableview/register(_:foridentifier:).md)
- [registeredNibsByIdentifier](appkit/nstableview/registerednibsbyidentifier.md)

### Target-action Behavior

- [doubleAction](appkit/nstableview/doubleaction.md)
- [clickedColumn](appkit/nstableview/clickedcolumn.md)
- [clickedRow](appkit/nstableview/clickedrow.md)

### Configuring Behavior

- [allowsColumnReordering](appkit/nstableview/allowscolumnreordering.md)
- [allowsColumnResizing](appkit/nstableview/allowscolumnresizing.md)
- [allowsMultipleSelection](appkit/nstableview/allowsmultipleselection.md)
- [allowsEmptySelection](appkit/nstableview/allowsemptyselection.md)
- [allowsColumnSelection](appkit/nstableview/allowscolumnselection.md)
- [usesAutomaticRowHeights](appkit/nstableview/usesautomaticrowheights.md)

### Setting Display Attributes

- [intercellSpacing](appkit/nstableview/intercellspacing.md)
- [rowHeight](appkit/nstableview/rowheight.md)
- [backgroundColor](appkit/nstableview/backgroundcolor.md)
- [usesAlternatingRowBackgroundColors](appkit/nstableview/usesalternatingrowbackgroundcolors.md)
- [style](appkit/nstableview/style-swift.property.md)
- [effectiveStyle](appkit/nstableview/effectivestyle.md)
- [NSTableView.Style](appkit/nstableview/style-swift.enum.md)
- [selectionHighlightStyle](appkit/nstableview/selectionhighlightstyle-swift.property.md)
- [gridColor](appkit/nstableview/gridcolor.md)
- [gridStyleMask](appkit/nstableview/gridstylemask.md)
- [indicatorImage(in:)](appkit/nstableview/indicatorimage(in:).md)
- [setIndicatorImage(_:in:)](appkit/nstableview/setindicatorimage(_:in:).md)

### Getting and Setting Row Size Styles

- [effectiveRowSizeStyle](appkit/nstableview/effectiverowsizestyle.md)
- [rowSizeStyle](appkit/nstableview/rowsizestyle-swift.property.md)

### Column Management

- [addTableColumn(_:)](appkit/nstableview/addtablecolumn(_:).md)
- [removeTableColumn(_:)](appkit/nstableview/removetablecolumn(_:).md)
- [moveColumn(_:toColumn:)](appkit/nstableview/movecolumn(_:tocolumn:).md)
- [tableColumns](appkit/nstableview/tablecolumns.md)
- [column(withIdentifier:)](appkit/nstableview/column(withidentifier:).md)
- [tableColumn(withIdentifier:)](appkit/nstableview/tablecolumn(withidentifier:).md)

### Selecting Columns and Rows

- [selectColumnIndexes(_:byExtendingSelection:)](appkit/nstableview/selectcolumnindexes(_:byextendingselection:).md)
- [selectedColumn](appkit/nstableview/selectedcolumn.md)
- [selectedColumnIndexes](appkit/nstableview/selectedcolumnindexes.md)
- [deselectColumn(_:)](appkit/nstableview/deselectcolumn(_:).md)
- [numberOfSelectedColumns](appkit/nstableview/numberofselectedcolumns.md)
- [isColumnSelected(_:)](appkit/nstableview/iscolumnselected(_:).md)
- [selectRowIndexes(_:byExtendingSelection:)](appkit/nstableview/selectrowindexes(_:byextendingselection:).md)
- [selectedRow](appkit/nstableview/selectedrow.md)
- [selectedRowIndexes](appkit/nstableview/selectedrowindexes.md)
- [deselectRow(_:)](appkit/nstableview/deselectrow(_:).md)
- [numberOfSelectedRows](appkit/nstableview/numberofselectedrows.md)
- [isRowSelected(_:)](appkit/nstableview/isrowselected(_:).md)
- [selectAll(_:)](appkit/nstableview/selectall(_:).md)
- [deselectAll(_:)](appkit/nstableview/deselectall(_:).md)

### Enumerating Table Rows

- [enumerateAvailableRowViews(_:)](appkit/nstableview/enumerateavailablerowviews(_:).md)

### Managing Type Select

- [allowsTypeSelect](appkit/nstableview/allowstypeselect.md)

### Table Dimensions

- [numberOfColumns](appkit/nstableview/numberofcolumns.md)
- [numberOfRows](appkit/nstableview/numberofrows.md)

### Getting and Setting Floating Rows

- [floatsGroupRows](appkit/nstableview/floatsgrouprows.md)

### Editing Cells

- [editColumn(_:row:with:select:)](appkit/nstableview/editcolumn(_:row:with:select:).md)
- [editedColumn](appkit/nstableview/editedcolumn.md)
- [editedRow](appkit/nstableview/editedrow.md)

### Adding and Deleting Row Views

- [didAdd(_:forRow:)](appkit/nstableview/didadd(_:forrow:).md)
- [didRemove(_:forRow:)](appkit/nstableview/didremove(_:forrow:).md)

### Setting Auxiliary Views

- [headerView](appkit/nstableview/headerview.md)
- [cornerView](appkit/nstableview/cornerview.md)

### Layout Support

- [userInterfaceLayoutDirection](appkit/nstableview/userinterfacelayoutdirection.md)
- [rect(ofColumn:)](appkit/nstableview/rect(ofcolumn:).md)
- [rect(ofRow:)](appkit/nstableview/rect(ofrow:).md)
- [rows(in:)](appkit/nstableview/rows(in:).md)
- [columnIndexes(in:)](appkit/nstableview/columnindexes(in:).md)
- [column(at:)](appkit/nstableview/column(at:).md)
- [row(at:)](appkit/nstableview/row(at:).md)
- [frameOfCell(atColumn:row:)](appkit/nstableview/frameofcell(atcolumn:row:).md)
- [columnAutoresizingStyle](appkit/nstableview/columnautoresizingstyle-swift.property.md)
- [sizeLastColumnToFit()](appkit/nstableview/sizelastcolumntofit().md)
- [noteNumberOfRowsChanged()](appkit/nstableview/notenumberofrowschanged().md)
- [tile()](appkit/nstableview/tile().md)
- [sizeToFit()](appkit/nstableview/sizetofit().md)
- [noteHeightOfRows(withIndexesChanged:)](appkit/nstableview/noteheightofrows(withindexeschanged:).md)

### Drawing

- [drawRow(_:clipRect:)](appkit/nstableview/drawrow(_:cliprect:).md)
- [drawGrid(inClipRect:)](appkit/nstableview/drawgrid(incliprect:).md)
- [highlightSelection(inClipRect:)](appkit/nstableview/highlightselection(incliprect:).md)
- [drawBackground(inClipRect:)](appkit/nstableview/drawbackground(incliprect:).md)

### Scrolling

- [scrollRowToVisible(_:)](appkit/nstableview/scrollrowtovisible(_:).md)
- [scrollColumnToVisible(_:)](appkit/nstableview/scrollcolumntovisible(_:).md)

### Table Column State Persistence

- [autosaveTableColumns](appkit/nstableview/autosavetablecolumns.md)
- [autosaveName](appkit/nstableview/autosavename-swift.property.md)
- [NSTableView.AutosaveName](appkit/nstableview/autosavename-swift.typealias.md)

### Accessing the Delegate

- [delegate](appkit/nstableview/delegate.md)

### Highlightable Column Headers

- [highlightedTableColumn](appkit/nstableview/highlightedtablecolumn.md)

### Dragging

- [dragImageForRows(with:tableColumns:event:offset:)](appkit/nstableview/dragimageforrows(with:tablecolumns:event:offset:).md)
- [canDragRows(with:at:)](appkit/nstableview/candragrows(with:at:).md)
- [setDraggingSourceOperationMask(_:forLocal:)](appkit/nstableview/setdraggingsourceoperationmask(_:forlocal:).md)
- [verticalMotionCanBeginDrag](appkit/nstableview/verticalmotioncanbegindrag.md)
- [draggingDestinationFeedbackStyle](appkit/nstableview/draggingdestinationfeedbackstyle-swift.property.md)
- [setDropRow(_:dropOperation:)](appkit/nstableview/setdroprow(_:dropoperation:).md)

### Sorting

- [sortDescriptors](appkit/nstableview/sortdescriptors.md)

### Row Actions

- [rowActionsVisible](appkit/nstableview/rowactionsvisible.md)

### Hiding and Showing Table Rows

- [hideRows(at:withAnimation:)](appkit/nstableview/hiderows(at:withanimation:).md)
- [unhideRows(at:withAnimation:)](appkit/nstableview/unhiderows(at:withanimation:).md)
- [hiddenRowIndexes](appkit/nstableview/hiddenrowindexes.md)

### Deprecated Methods

- [focusedColumn()](appkit/nstableview/focusedcolumn().md)
- [setFocusedColumn(_:)](appkit/nstableview/setfocusedcolumn(_:).md)
- [shouldFocusCell(_:atColumn:row:)](appkit/nstableview/shouldfocuscell(_:atcolumn:row:).md)
- [performClickOnCell(atColumn:row:)](appkit/nstableview/performclickoncell(atcolumn:row:).md)
- [preparedCell(atColumn:row:)](appkit/nstableview/preparedcell(atcolumn:row:).md)

### Constants

- [Specifying a Custom Row View in a Nib File](appkit/specifying-a-custom-row-view-in-a-nib-file.md)
- [NSTableView.DraggingDestinationFeedbackStyle](appkit/nstableview/draggingdestinationfeedbackstyle-swift.enum.md)
- [NSTableView.DropOperation](appkit/nstableview/dropoperation.md)
- [NSTableView.GridLineStyle](appkit/nstableview/gridlinestyle.md)
- [NSTableView.ColumnAutoresizingStyle](appkit/nstableview/columnautoresizingstyle-swift.enum.md)
- [NSTableView.SelectionHighlightStyle](appkit/nstableview/selectionhighlightstyle-swift.enum.md)
- [NSTableView.AnimationOptions](appkit/nstableview/animationoptions.md)
- [NSTableView.RowSizeStyle](appkit/nstableview/rowsizestyle-swift.enum.md)
- [NSTableView.RowActionEdge](appkit/nstableview/rowactionedge.md)

### Notifications

- [columnDidMoveNotification](appkit/nstableview/columndidmovenotification.md)
- [columnDidResizeNotification](appkit/nstableview/columndidresizenotification.md)
- [selectionDidChangeNotification](appkit/nstableview/selectiondidchangenotification.md)
- [selectionIsChangingNotification](appkit/nstableview/selectionischangingnotification.md)

### Structures

- [NSTableView.ColumnDidMoveMessage](appkit/nstableview/columndidmovemessage.md)
- [NSTableView.ColumnDidResizeMessage](appkit/nstableview/columndidresizemessage.md)
- [NSTableView.SelectionDidChangeMessage](appkit/nstableview/selectiondidchangemessage.md)
- [NSTableView.SelectionIsChangingMessage](appkit/nstableview/selectionischangingmessage.md)

### Instance Properties

- [appIntentsDataSource](appkit/nstableview/appintentsdatasource.md)

## Relationships

### Inherits From

- [NSControl](appkit/nscontrol.md)

### Inherited By

- [NSOutlineView](appkit/nsoutlineview.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSAccessibilityElementProtocol](appkit/nsaccessibilityelementprotocol.md)
- [NSAccessibilityGroup](appkit/nsaccessibilitygroup.md)
- [NSAccessibilityProtocol](appkit/nsaccessibilityprotocol.md)
- [NSAccessibilityTable](appkit/nsaccessibilitytable.md)
- [NSAnimatablePropertyContainer](appkit/nsanimatablepropertycontainer.md)
- [NSAppearanceCustomization](appkit/nsappearancecustomization.md)
- [NSCoding](foundation/nscoding.md)
- [NSDraggingDestination](appkit/nsdraggingdestination.md)
- [NSDraggingSource](appkit/nsdraggingsource.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSStandardKeyBindingResponding](appkit/nsstandardkeybindingresponding.md)
- [NSTextDelegate](appkit/nstextdelegate.md)
- [NSTextViewDelegate](appkit/nstextviewdelegate.md)
- [NSTouchBarProvider](appkit/nstouchbarprovider.md)
- [NSUserActivityRestoring](appkit/nsuseractivityrestoring.md)
- [NSUserInterfaceItemIdentification](appkit/nsuserinterfaceitemidentification.md)
- [NSUserInterfaceValidations](appkit/nsuserinterfacevalidations.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Views

- [NSTableCellView](appkit/nstablecellview.md)
