| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.0 and later.
|
| Declared in | NSTableView.h |
| Companion guides |
An NSTableView object displays record-oriented data in a table and allows the user to edit values and resize and rearrange columns.
A data source
Table columns
dataSourceReturns the object providing the data that the table view displays.
tableColumnsReturns the NSTableColumn objects representing attributes for the table view.
selectedColumnReturns the index of the selected column.
selectedRowReturns the index of the selected row.
numberOfRowsReturns the number of rows in the table view.
reloadDataInforms the table view that data has changed and needs to be retrieved and displayed again.
An NSTableView object displays data for a set of related records, with rows representing individual records and columns representing the attributes of those records.
A table view is usually displayed in a scroll view, like this:

A table view does not store its own data, instead it retrieves data values as needed from a data source to which it has a weak reference (see Communicating With Objects). You should not, therefore, try to directly set data values programmatically in the table view; instead you should modify the values in the data source and allow the changes to be reflected in the table view. See the NSTableDataSource informal protocol, which declares the methods that an NSTableView object uses to access the contents of its data source object.
– setAllowsColumnReordering:
– allowsColumnReordering
– setAllowsColumnResizing:
– allowsColumnResizing
– setAllowsMultipleSelection:
– allowsMultipleSelection
– setAllowsEmptySelection:
– allowsEmptySelection
– setAllowsColumnSelection:
– allowsColumnSelection
– setIntercellSpacing:
– intercellSpacing
– setRowHeight:
– rowHeight
– setBackgroundColor:
– backgroundColor
– setUsesAlternatingRowBackgroundColors:
– usesAlternatingRowBackgroundColors
– selectionHighlightStyle
– setSelectionHighlightStyle:
– setGridColor:
– gridColor
– setGridStyleMask:
– gridStyleMask
– indicatorImageInTableColumn:
– setIndicatorImage:inTableColumn:
– addTableColumn:
– removeTableColumn:
– moveColumn:toColumn:
– tableColumns
– columnWithIdentifier:
– tableColumnWithIdentifier:
– selectColumnIndexes:byExtendingSelection:
– selectRowIndexes:byExtendingSelection:
– selectedColumnIndexes
– selectedRowIndexes
– deselectColumn:
– deselectRow:
– numberOfSelectedColumns
– numberOfSelectedRows
– selectedColumn
– selectedRow
– isColumnSelected:
– isRowSelected:
– selectAll:
– deselectAll:
– allowsTypeSelect
– setAllowsTypeSelect:
– tableView:willDisplayCell:forTableColumn:row: delegate method
– preparedCellAtColumn:row:
– tableView:dataCellForTableColumn:row: delegate method
– tableView:shouldShowCellExpansion:forTableColumn:row: delegate method
– tableView:isGroupRow: delegate method
– editColumn:row:withEvent:select:
– editedColumn
– editedRow
– tableView:shouldEditTableColumn:row: delegate method
– rectOfColumn:
– rectOfRow:
– columnsInRect:
– rowsInRect:
– columnIndexesInRect:
– columnAtPoint:
– rowAtPoint:
– frameOfCellAtColumn:row:
– columnAutoresizingStyle
– setColumnAutoresizingStyle:
– sizeLastColumnToFit
– noteNumberOfRowsChanged
– tile
– sizeToFit
– noteHeightOfRowsWithIndexesChanged:
– tableView:heightOfRow: delegate method
– drawRow:clipRect:
– drawGridInClipRect:
– highlightSelectionInClipRect:
– drawBackgroundInClipRect:
– selectionShouldChangeInTableView: delegate method
– tableView:shouldSelectRow: delegate method
– tableView:selectionIndexesForProposedSelection: delegate method
– tableView:shouldSelectTableColumn: delegate method
– tableViewSelectionIsChanging: delegate method
– tableViewSelectionDidChange: delegate method
– tableView:shouldTypeSelectForEvent:withCurrentSearchString: delegate method
– tableView:typeSelectStringForTableColumn:row: delegate method
– tableView:nextTypeSelectMatchFromRow:toRow:forString: delegate method
– dragImageForRowsWithIndexes:tableColumns:event:offset:
– canDragRowsWithIndexes:atPoint:
– setDraggingSourceOperationMask:forLocal:
– setDropRow:dropOperation:
– setVerticalMotionCanBeginDrag:
– verticalMotionCanBeginDrag
– tableView:didDragTableColumn: delegate method
– tableViewColumnDidMove: delegate method
– tableViewColumnDidResize: delegate method
– tableView:didClickTableColumn: delegate method
– tableView:mouseDownInHeaderOfTableColumn: delegate method
– tableView:shouldTrackCell:forTableColumn:row: delegate method
– textShouldBeginEditing:
– textDidBeginEditing:
– textDidChange:
– textShouldEndEditing:
– textDidEndEditing:
– tableView:toolTipForCell:rect:tableColumn:row:mouseLocation: delegate method
– autoresizesAllColumnsToFit
– drawsGrid Deprecated in Mac OS X v10.3
– selectColumn:byExtendingSelection: Deprecated in Mac OS X v10.3
– selectedColumnEnumerator Deprecated in Mac OS X v10.3
– selectedRowEnumerator Deprecated in Mac OS X v10.3
– selectRow:byExtendingSelection: Deprecated in Mac OS X v10.3
– setDrawsGrid: Deprecated in Mac OS X v10.3
– dragImageForRows:event:dragImageOffset: Deprecated in Mac OS X v10.4 and later
– setAutoresizesAllColumnsToFit: Deprecated in Mac OS X v10.4 and later
Adds a given column as the last column of the receiver.
- (void)addTableColumn:(NSTableColumn *)aColumn
The column to add to the receiver.
NSTableView.h
Returns a Boolean value that indicates whether the receiver allows the user to rearrange columns by dragging their headers.
- (BOOL)allowsColumnReordering
YES to allow the user to rearrange columns by dragging their headers, otherwise NO.
The default is YES. You can rearrange columns programmatically regardless of this setting.
NSTableView.h
Returns a Boolean value that indicates whether the receiver allows the user to resize columns by dragging between their headers.
- (BOOL)allowsColumnResizing
YES if the receiver allows the user to resize columns by dragging between their headers, otherwise NO.
The default is YES. You can resize columns programmatically regardless of this setting.
– setWidth: (NSTableColumn)– setAllowsColumnResizing:NSTableView.h
Returns a Boolean value that indicates whether the receiver allows the user to select columns by clicking their headers.
- (BOOL)allowsColumnSelection
YES if the receiver allows the user to select columns by clicking their headers, otherwise NO.
The default is NO. You can select columns programmatically regardless of this setting.
NSTableView.h
Returns a Boolean value that indicates whether the receiver allows the user to select zero columns or rows.
- (BOOL)allowsEmptySelection
YES if the receiver allows the user to select zero columns or rows, otherwise NO.
The default is YES.
You cannot set an empty selection programmatically if this setting is NO, unlike with the other settings that affect selection behavior.
NSTableView.h
Returns a Boolean value that indicates whether the receiver allows the user to select more than one column or row at a time.
- (BOOL)allowsMultipleSelection
YES if the receiver allows the user to select more than one column or row at a time, otherwise NO.
The default is NO. You can select multiple columns or rows programmatically regardless of this setting.
– selectColumn:byExtendingSelection:– selectRow:byExtendingSelection:– setAllowsMultipleSelection:NSTableView.hReturns a Boolean value that indicates whether the receiver allows the user to type characters to select rows.
- (BOOL)allowsTypeSelect
YES if the receiver allows type selection, otherwise NO.
The default value is YES.
NSTableView.hReturns YES if the receiver proportionally resizes its columns to fit when its superview’s frame changes, NO if it only resizes the last column. (Deprecated. Use columnAutoresizingStyle instead.)
- (BOOL)autoresizesAllColumnsToFit
NSTableView.hReturns the name under which table information is automatically saved.
- (NSString *)autosaveName
The name under which table information is automatically saved. If no name has been set, returns nil.
The table information is saved separately for each user and for each application that user uses.
Note that even when a table view has an autosave name, it may not be saving table information automatically. To check whether table information is being saved automatically, use autosaveTableColumns.
NSTableView.hReturns a Boolean value that indicates whether the order and width of the receiver’s columns are automatically saved.
- (BOOL)autosaveTableColumns
The table information is saved separately for each user and for each application that user uses. Note that if autosaveName returns nil, this setting is ignored and table information isn’t saved.
NSTableView.h
Returns the color used to draw the background of the receiver.
- (NSColor *)backgroundColor
The color used to draw the background of the receiver.
The default background color is light gray.
NSTableView.hReturns whether the receiver allows dragging the rows at rowIndexes with a drag initiated at mousedDownPoint.
- (BOOL)canDragRowsWithIndexes:(NSIndexSet *)rowIndexes atPoint:(NSPoint)mouseDownPoint
Return NO to disallow the drag.
NSTableView.h
Returns the index of the column the user clicked to trigger an action message.
- (NSInteger)clickedColumn
The index of the column the user clicked to trigger an action message. Returns –1 if the user clicked in an area of the table view not occupied by columns.
The return value of this method is meaningful only in the target’s implementation of the action or double-action method.
– clickedRow– setAction: (NSControl)– setDoubleAction:NSTableView.h
Returns the index of the row the user clicked to trigger an action message.
- (NSInteger)clickedRow
The index of the row the user clicked to trigger an action message. Returns –1 if the user clicked in an area of the table view not occupied by table rows.
The return value of this method is meaningful only in the target’s implementation of the action or double-action method.
– clickedColumn– setAction: (NSControl)– setDoubleAction:NSTableView.h
Returns the index of the column a given point lies in.
- (NSInteger)columnAtPoint:(NSPoint)aPoint
A point in the coordinate system of the receiver.
The index of the column aPoint lies in, or –1 if aPoint lies outside the receiver’s bounds.
NSTableView.hReturns the receiver’s column autoresizing style.
- (NSTableViewColumnAutoresizingStyle)columnAutoresizingStyle
The receiver’s column autoresizing style. For possible values, see “Autoresizing Styles.”
NSTableView.hReturns the indexes of the receiver’s columns that intersect the specified rectangle.