| 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 | |
| Related sample code |
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 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:
– selectedColumn
– selectedColumnIndexes
– deselectColumn:
– numberOfSelectedColumns
– isColumnSelected:
– selectRowIndexes:byExtendingSelection:
– selectedRow
– selectedRowIndexes
– deselectRow:
– numberOfSelectedRows
– isRowSelected:
– selectAll:
– deselectAll:
– rectOfColumn:
– rectOfRow:
– rowsInRect:
– columnIndexesInRect:
– columnAtPoint:
– rowAtPoint:
– frameOfCellAtColumn:row:
– columnAutoresizingStyle
– setColumnAutoresizingStyle:
– sizeLastColumnToFit
– noteNumberOfRowsChanged
– tile
– sizeToFit
– noteHeightOfRowsWithIndexesChanged:
– columnsInRect: Deprecated in Mac OS X v10.5
– drawRow:clipRect:
– drawGridInClipRect:
– highlightSelectionInClipRect:
– drawBackgroundInClipRect:
– dragImageForRowsWithIndexes:tableColumns:event:offset:
– canDragRowsWithIndexes:atPoint:
– setDraggingSourceOperationMask:forLocal:
– setVerticalMotionCanBeginDrag:
– verticalMotionCanBeginDrag
– draggingDestinationFeedbackStyle
– setDraggingDestinationFeedbackStyle:
– setDropRow:dropOperation:
– textShouldBeginEditing:
– textDidBeginEditing:
– textDidChange:
– textShouldEndEditing:
– textDidEndEditing:
– 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
– autoresizesAllColumnsToFit Deprecated in Mac OS X v10.4
– dragImageForRows:event:dragImageOffset: Deprecated in Mac OS X v10.4
– setAutoresizesAllColumnsToFit: Deprecated in Mac OS X v10.4
– tableView:writeRows:toPasteboard: delegate method Deprecated in Mac OS X v10.4
Adds a given column as the last column of the receiver.
- (void)addTableColumn:(NSTableColumn *)aColumn
The column to add to the receiver.
NSTableView.hReturns a Boolean value that indicates whether the receiver allows the user to rearrange columns by dragging their headers.
- (BOOL)allowsColumnReordering
The default is YES. You can rearrange columns programmatically regardless of this setting.
NSTableView.hReturns 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.hReturns 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.hReturns a Boolean value that indicates whether the receiver allows the user to select zero columns or rows.
- (BOOL)allowsEmptySelection
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.hReturns 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 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.hReturns 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.hReturns 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.hReturns 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.hReturns 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.
- (NSIndexSet *)columnIndexesInRect:(NSRect)rect
The rectangle in the receiver’s coordinate system to test for column enclosure.
New NSIndexSet object containing the indexes of the receiver’s columns that intersect with rect.
Columns that return YES for the NSTableColumn method isHidden are excluded from the results.
NSTableView.hReturns the index of the first column in the receiver whose identifier is equal to a given identifier.
- (NSInteger)columnWithIdentifier:(id)anObject
A column identifier.
The index of the first column in the receiver whose identifier is equal to anObject (when compared using isEqual:) or –1 if no columns are found with the specified identifier.
NSTableView.hReturns the view used to draw the area to the right of the column headers and above the vertical scroller of the enclosing scroll view.
- (NSView *)cornerView
The view used to draw the area to the right of the column headers and above the vertical scroller of the enclosing NSScrollView object.
This is by default a simple view that merely fills in its frame, but you can replace it with a custom view using setCornerView:.
NSTableView.hReturns the object that provides the data displayed by the receiver.
- (id < NSTableViewDataSource >)dataSource
The object that provides the data displayed by the receiver.
See Using a Table Data Source and the NSTableDataSource informal protocol specification for more information.
NSTableView.hReturns the receiver’s delegate.
- (id < NSTableViewDelegate >)delegate
The receiver’s delegate.
NSTableView.hDeselects all selected rows or columns if empty selection is allowed; otherwise does nothing.
- (void)deselectAll:(id)sender
Typically the object that sent the message.
Posts NSTableViewSelectionDidChangeNotification to the default notification center if the selection does in fact change.
As a target-action method, deselectAll: checks with the delegate before changing the selection, using selectionShouldChangeInTableView:.
– allowsEmptySelection– selectAll:– selectColumn:byExtendingSelection:– selectionShouldChangeInTableView: (NSTableViewDelegate)NSTableView.hDeselects the column at a given index if it’s selected.
- (void)deselectColumn:(NSInteger)columnIndex
The index of the column to deselect.
Deselects the column at columnIndex if it’s selected, regardless of whether empty selection is allowed.
If the selection does in fact change, posts NSTableViewSelectionDidChangeNotification to the default notification center.
If the indicated column was the last column selected by the user, the column nearest it effectively becomes the last selected column. In case of a tie, priority is given to the column on the left.
This method doesn’t check with the delegate before changing the selection.
NSTableView.hDeselects the row at a given index if it’s selected.
- (void)deselectRow:(NSInteger)rowIndex
The index of the row to deselect.
Deselects the row at rowIndex if it’s selected, regardless of whether empty selection is allowed.
If the selection does in fact change, posts NSTableViewSelectionDidChangeNotification to the default notification center.
If the indicated row was the last row selected by the user, the row nearest it effectively becomes the last selected row. In case of a tie, priority is given to the row above.
This method doesn’t check with the delegate before changing the selection.
NSTableView.hReturns the message sent to the target when the user double-clicks a column header or an uneditable cell.
- (SEL)doubleAction
The message the receiver sends to its target when the user double-clicks a column header or an uneditable cell.
– action (NSControl)– target (NSControl)– setDoubleAction:NSTableView.hReturns the feedback style displayed when the user drags over the table view.
- (NSTableViewDraggingDestinationFeedbackStyle)draggingDestinationFeedbackStyle
The dragging feedback style. See “NSTableViewDraggingDestinationFeedbackStyle” for the possible values.
NSTableView.hComputes and returns an image to use for dragging.
- (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows tableColumns:(NSArray *)tableColumns event:(NSEvent *)dragEvent offset:(NSPointPointer)dragImageOffset
Override this to return a custom image. dragRows represents the rows participating in the drag. tableColumns represents the table columns that should be in the output image. dragEvent is a reference to the mouse-down event that began the drag. dragImageOffset is an in/out parameter.
This method is called with dragImageOffset set to NSZeroPoint, but it can be modified to reposition the returned image. A dragImageOffset of NSZeroPoint will cause the image to be centered under the cursor.
NSTableView.hDraws the background in the clip rect specified by clipRect.
- (void)drawBackgroundInClipRect:(NSRect)clipRect
NSTableView.hDraws the grid lines within aRect, using the grid color set with setGridColor:.
- (void)drawGridInClipRect:(NSRect)aRect
This method draws a grid regardless of whether the receiver is set to draw one automatically.
Subclasses can override this method to draw grid lines other than the standard ones.
NSTableView.hDraws the cells for the row at rowIndex in the columns that intersect clipRect.
- (void)drawRow:(NSInteger)rowIndex clipRect:(NSRect)clipRect
Sends tableView:willDisplayCell:forTableColumn:row: to the delegate before drawing each cell.
Subclasses can override this method to customize their appearance.
NSTableView.hEdits the cell at columnIndex and rowIndex, selecting its entire contents if flag is YES.
- (void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag
This method is invoked automatically in response to user actions; you should rarely need to invoke it directly. theEvent is usually the mouse event that triggered editing; it can be nil when starting an edit programmatically.
This method scrolls the receiver so that the cell is visible, sets up the field editor, and sends selectWithFrame:inView:editor:delegate:start:length: and editWithFrame:inView:editor:delegate:event: to the field editor’s NSCell object with the NSTableView as the text delegate.
The row at rowIndex must be selected prior to calling editColumn:row:withEvent:select:, or an exception will be raised.
NSTableView.hReturns the index of the column being edited.
- (NSInteger)editedColumn
If sent during editColumn:row:withEvent:select:, the index of the column being edited; otherwise –1.
NSTableView.hReturns the index of the row being edited.
- (NSInteger)editedRow
If sent during editColumn:row:withEvent:select:, the index of the row being edited; otherwise –1.
NSTableView.hReturns the currently focused column.
- (NSInteger)focusedColumn
The index of the column, or -1 if there is no focused column
The focus interaction will always be on the selectedRow of the table. If the selectedRow is a full width cell, then focusedColumn will return 1 when focused..
NSTableView.hReturns a rectangle locating the cell that lies at the intersection of columnIndex and rowIndex.
- (NSRect)frameOfCellAtColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex
The index of the column containing the cell whose rectangle you want.
The index of the row containing the cell whose rectangle you want.
A rectangle locating the cell that lies at the intersection of columnIndex and rowIndex. Returns NSZeroRect if columnIndex or rowIndex is greater than the number of columns or rows in the receiver.
You can use this method to update a single cell more efficiently than sending the table view a reloadData message.
[aTableView setNeedsDisplayInRect:[aTableView frameOfCellAtColumn:column row:row]]; |
The result of this method is used in a drawWithFrame:inView: message to the table column's data cell.
NSTableView.hReturns the color used to draw grid lines.
- (NSColor *)gridColor
The color used to draw grid lines.
The default color is gray.
NSTableView.hReturns the receiver’s grid style mask.
- (NSUInteger)gridStyleMask
The receiver’s grid style mask. Possible return values are described in “Grid styles.”
NSTableView.hReturns the NSTableHeaderView object used to draw headers over columns.
- (NSTableHeaderView *)headerView
The NSTableHeaderView object used to draw headers over columns, or nil if the receiver has no header view
See The Parts of a Table and the NSTableHeaderView class specification for more information.
NSTableView.hReturns the table column highlighted in the receiver.
- (NSTableColumn *)highlightedTableColumn
The table column highlighted in the receiver.
A highlightable column header can be used in conjunction with row selection to highlight a particular column of the table. An example of this is how the Mail application indicates the currently sorted column.
NSTableView.hHighlights the region of the receiver in clipRect.
- (void)highlightSelectionInClipRect:(NSRect)clipRect
This method is invoked before drawRow:clipRect:.
Subclasses can override this method to change the manner in which they highlight selections.
NSTableView.hReturns the indicator image of a given table column.
- (NSImage *)indicatorImageInTableColumn:(NSTableColumn *)aTableColumn
A table column in the receiver.
An indicator image is an arbitrary (small) image that is rendered on the right side of the column header. An example of its use is in Mail to indicate the sorting direction of the currently sorted column in a mailbox.
NSTableView.hReturns the horizontal and vertical spacing between cells.
- (NSSize)intercellSpacing
The horizontal and vertical spacing between cells.
The default spacing is (3.0, 2.0).
NSTableView.hReturns a Boolean value that indicates whether the column at a given index is selected.
- (BOOL)isColumnSelected:(NSInteger)columnIndex
The index of the column to test.
NSTableView.hReturns a Boolean value that indicates whether the row at a given index is selected.
- (BOOL)isRowSelected:(NSInteger)rowIndex
The index of the row to test.
NSTableView.hMoves the column and heading at a given index to a new given index.
- (void)moveColumn:(NSInteger)columnIndex toColumn:(NSInteger)newIndex
The current index of the column to move.
The new index for the moved column.
This method posts NSTableViewColumnDidMoveNotification to the default notification center.
NSTableView.hInforms the receiver that the rows specified in indexSet have changed height.
- (void)noteHeightOfRowsWithIndexesChanged:(NSIndexSet *)indexSet
If the delegate implements tableView:heightOfRow: this method immediately re-tiles the table view using the row heights the delegate provides.
NSTableView.hInforms the receiver that the number of records in its data source has changed.
- (void)noteNumberOfRowsChanged
This method allows the receiver to update the scrollers in its scroll view without actually reloading data into the receiver. It’s useful for a data source that continually receives data in the background over a period of time, in which case the table view can remain responsive to the user while the data is received.
See the NSTableDataSource informal protocol specification for information on the messages an NSTableView object sends to its data source.
– reloadData– numberOfRowsInTableView: (NSTableDataSource informal protocol)NSTableView.hReturns the number of columns in the receiver.
- (NSInteger)numberOfColumns
The number of columns in the receiver.
The value returned includes table columns that are currently hidden.
NSTableView.hReturns the number of rows in the receiver.
- (NSInteger)numberOfRows
The number of rows in the receiver.
Typically you should not ask the table view how many rows it has; instead you should interrogate the table view's data source.
– numberOfColumns– numberOfRowsInTableView: (NSTableDataSource informal protocol)NSTableView.hReturns the number of selected columns.
- (NSInteger)numberOfSelectedColumns
The number of selected columns.
NSTableView.hReturns the number of selected rows.
- (NSInteger)numberOfSelectedRows
The number of selected rows.
NSTableView.hPerforms a click action on the cell at the specified row and column.
- (void)performClickOnCellAtColumn:(NSInteger)column row:(NSInteger)row
The column of the cell.
The row of the cell.
Acquires the preparedCellAtColumn:row:, copies it, invokes performClick: or performClickWithFrame:inView: (if the cell is an NSPopUpButtonCell), and then updates the datasource, if required. This method does not do any checks to see if the cell is enabled.
NSTableView.hReturns the fully prepared cell that the receiver will use for drawing or processing of the specified row and column.
- (NSCell *)preparedCellAtColumn:(NSInteger)column row:(NSInteger)row
The column index for which to return the appropriate cell.
The row index for which to return the appropriate cell.
New NSCell subclass instance to use for the specified row and column. The value for the cell is correctly set, and the delegate method tableView:willDisplayCell:forTableColumn:row: will have been called.
You can override this method to do any additional cell set up that is required, or invoke it to retrieve a cell that has its contents configured for the specified column and row.
NSTableView.hReturns the rectangle containing the column at a given index.
- (NSRect)rectOfColumn:(NSInteger)columnIndex
The index of a column in the receiver.
The rectangle containing the column at columnIndex. Returns NSZeroRect if columnIndex lies outside the range of valid column indices for the receiver.
You can use this method to update a single column more efficiently than sending the table view a reloadData message.
[aTableView setNeedsDisplayInRect:[aTableView rectOfColumn:column]]; |
– frameOfCellAtColumn:row:– rectOfRow:– headerRectOfColumn: (NSTableHeaderView)NSTableView.hReturns the rectangle containing the row at a given index.
- (NSRect)rectOfRow:(NSInteger)rowIndex
The rectangle containing the row at rowIndex. Returns NSZeroRect if rowIndex lies outside the range of valid row indices for the receiver.
You can use this method to update a single row more efficiently than sending the table view a reloadData message.
[aTableView setNeedsDisplayInRect:[aTableView rectOfRow:row]]; |
NSTableView.hMarks the receiver as needing redisplay, so it will reload the data for visible cells and draw the new values.
- (void)reloadData
This method forces redraw of all the visible cells in the receiver. If you want to update the value in a single cell, column, or row, it is more efficient to use frameOfCellAtColumn:row:, rectOfColumn:, or rectOfRow: in conjunction with setNeedsDisplayInRect: (NSView). If you just want to update the scroller, use noteNumberOfRowsChanged; if the height of a set of rows changes, use noteHeightOfRowsWithIndexesChanged:.
– noteNumberOfRowsChanged– noteHeightOfRowsWithIndexesChanged:– frameOfCellAtColumn:row:– rectOfColumn:– rectOfRow:NSTableView.hReloads the data for only the specified rows and columns.
- (void)reloadDataForRowIndexes:(NSIndexSet *)rowIndexes columnIndexes:(NSIndexSet *)columnIndexes
The indexes of the rows to update.
The indexes of the columns to update.
For cells that are visible, the appropriate dataSource and delegate methods will be called and the cells will be redrawn.
For tables that support variable row heights, the row height will not be re-queried from the delegate; it is your responsibility to invoke noteHeightOfRowsWithIndexesChanged: should be used if a row height change is required.
NSTableView.hRemoves a given column from the receiver.
- (void)removeTableColumn:(NSTableColumn *)aTableColumn
The column to remove from the receiver.
NSTableView.hReturns the index of the row a given point lies in.
- (NSInteger)rowAtPoint:(NSPoint)aPoint
A point in the coordinate system of the receiver.
The index of the row aPoint lies in, or –1 if aPoint lies outside the receiver’s bounds.
NSTableView.hReturns the height of each row in the receiver.
- (CGFloat)rowHeight
The height of each row in the receiver.
The default row height is 16.0.
NSTableView.hReturns a range of indices for the rows that lie wholly or partially within the vertical boundaries of a given rectangle.
- (NSRange)rowsInRect:(NSRect)aRect
A rectangle in the coordinate system of the receiver.
A range of indices for the receiver’s rows that lie wholly or partially within the horizontal boundaries of aRect. If the width or height of aRect is 0, returns an NSRange whose length is 0.
The location of the range is the first such row’s index, and the length is the number of rows that lie in aRect.
NSTableView.hScrolls the receiver and header view horizontally in an enclosing NSClipView so the column specified by columnIndex is visible.
- (void)scrollColumnToVisible:(NSInteger)columnIndex
– scrollRowToVisible:– scrollToPoint: (NSClipView)NSTableView.hScrolls the receiver vertically in an enclosing NSClipView so the row specified by rowIndex is visible.
- (void)scrollRowToVisible:(NSInteger)rowIndex
– scrollColumnToVisible:– scrollToPoint: (NSClipView)NSTableView.hSelects all rows or all columns, according to whether rows or columns were most recently selected.
- (void)selectAll:(id)sender
Typically the object that sent the message.
If the table allows multiple selection, this action method selects all rows or all columns, according to whether rows or columns were most recently selected. If nothing has been recently selected, this method selects all rows. If this table doesn’t allow multiple selection, this method does nothing.
If the selection does change, this method posts NSTableViewSelectionDidChangeNotification to the default notification center.
As a target-action method, selectAll: checks with the delegate before changing the selection.
NSTableView.hSets the column selection using indexes.
- (void)selectColumnIndexes:(NSIndexSet *)indexes byExtendingSelection:(BOOL)extend
If the extend flag is NO the selected columns are specified by indexes. If extend is YES, the columns indicated by indexes are added to the collection of already selected columns, providing multiple selection.
If a subclass implements only the deprecated selectColumn:byExtendingSelection: method, then this method will be invoked in a loop. If a subclass implements this method, then selectColumn:byExtendingSelection: is not used. This allows subclasses that already implement selectColumn:byExtendingSelection: to still receive all selection messages. To avoid cycles, implementations of this method and selectColumn:byExtendingSelection: should not invoke each other.
NSTableView.hReturns the index of the last column selected or added to the selection.
- (NSInteger)selectedColumn
The index of the last column selected or added to the selection, or –1 if no column is selected.
– selectedColumnEnumerator– numberOfSelectedColumns– selectColumn:byExtendingSelection:– deselectColumn:NSTableView.hReturns an index set containing the indexes of the selected columns.
- (NSIndexSet *)selectedColumnIndexes
An index set containing the indexes of the selected columns.
NSTableView.hReturns the index of the last row selected or added to the selection.
- (NSInteger)selectedRow
The index of the last row selected or added to the selection, or –1 if no row is selected.
NSTableView.hReturns an index set containing the indexes of the selected rows.
- (NSIndexSet *)selectedRowIndexes
An index set containing the indexes of the selected rows.
NSTableView.hReturns the selection highlight style used by the receiver to indicate row and column selection.
- (NSTableViewSelectionHighlightStyle)selectionHighlightStyle
The selection highlight style used by the receiver to use to indicate row and column selection. See “Selection Styles” for the possible values.
NSTableView.hSets the row selection using indexes.
- (void)selectRowIndexes:(NSIndexSet *)indexes byExtendingSelection:(BOOL)extend
If the extend flag is NO the selected rows are specified by indexes. If extend is YES, the rows indicated by indexes are added to the collection of already selected rows, providing multiple selection.
If a subclass implements only the deprecated selectRow:byExtendingSelection: method, then that method will be invoked in a loop. This allows subclasses that already implement selectRow:byExtendingSelection: to still receive all selection messages. If a subclass implements selectRowIndexes:byExtendingSelection:, then selectRow:byExtendingSelection: is not used. Note that to avoid cycles, implementations of this method and selectRow:byExtendingSelection: should not invoke each other.
NSTableView.hControls whether the user can drag column headers to reorder columns.
- (void)setAllowsColumnReordering:(BOOL)flag
The default is YES. You can rearrange columns programmatically regardless of this setting.
NSTableView.hControls whether the user can resize columns by dragging between headers.
- (void)setAllowsColumnResizing:(BOOL)flag
The default is YES. You can resize columns programmatically regardless of this setting.
– setWidth: (NSTableColumn)– allowsColumnResizingNSTableView.hControls whether the user can select an entire column by clicking its header.
- (void)setAllowsColumnSelection:(BOOL)flag
The default is NO. You can select columns programmatically regardless of this setting.
NSTableView.hControls whether the receiver allows zero rows or columns to be selected.
- (void)setAllowsEmptySelection:(BOOL)flag
The default is YES.
Unlike with the other settings that affect selection behavior, you cannot set an empty selection programmatically if empty selection is disallowed.
NSTableView.hControls whether the user can select more than one row or column at a time.
- (void)setAllowsMultipleSelection:(BOOL)flag
The default is NO. You can select multiple columns or rows programmatically regardless of this setting.
NSTableView.hSets whether the receiver allows the user to type characters to select rows.
- (void)setAllowsTypeSelect:(BOOL)value
YES if the receiver allows type selection, otherwise NO.
NSTableView.hSets the name under which table information is automatically saved to name.
- (void)setAutosaveName:(NSString *)name
If name is different from the current name, this method also reads in the saved information and sets the order and width of this table view’s columns to match.
The table information is saved separately for each user and for each application that user uses. Note that even though a table view has an autosave name, it may not be saving table information automatically. To set whether table information is being saved automatically, use setAutosaveTableColumns:.
NSTableView.hSets whether the order and width of this table view’s columns are automatically saved.
- (void)setAutosaveTableColumns:(BOOL)flag
If flag is different from the current value, this method also reads in the saved information and sets the table options to match.
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.hSets the receiver’s background color to a given color.
- (void)setBackgroundColor:(NSColor *)aColor
The background color for the receiver.
– setNeedsDisplay: (NSView)– backgroundColorNSTableView.hSets the column autoresizing style of the receiver to a given style.
- (void)setColumnAutoresizingStyle:(NSTableViewColumnAutoresizingStyle)style
The column autoresizing style for the receiver. For possible values, see “Autoresizing Styles.”
NSTableView.hSets the receiver’s corner view to a given view.
- (void)setCornerView:(NSView *)aView
The corner view for the receiver.
The default corner view merely draws a bezeled rectangle using a blank NSTableHeaderCell object, but you can replace it with a custom view that displays an image or with a control that can handle mouse events, such as a select all button. Your custom corner view should be as wide as a vertical NSScroller object and as tall as the receiver’s header view.
NSTableView.hSets the receiver’s data source to a given object.
- (void)setDataSource:(id < NSTableViewDataSource >)anObject
The data source for the receiver. The object must implement the appropriate methods of the NSTableDataSource informal protocol.
In a managed memory environment, the receiver maintains a weak reference to the data source (that is, it does not retain the data source, see Communicating With Objects). After setting the data source, this method invokes tile.
This method raises an NSInternalInconsistencyException if anObject doesn’t respond to either numberOfRowsInTableView: or tableView:objectValueForTableColumn:row:.
NSTableView.hSets the receiver’s delegate to a given object.
- (void)setDelegate:(id < NSTableViewDelegate >)anObject
The delegate for the receiver.
In a managed memory environment, the receiver maintains a weak reference to the delegate (that is, it does not retain the delegate, see Communicating With Objects).
NSTableView.hSets the message sent to the target when the user double-clicks an uneditable cell or a column header to a given selector.
- (void)setDoubleAction:(SEL)aSelector
The message the receiver sends to its target when the user double-clicks an uneditable cell or a column header.
If the double-clicked cell is editable, this message isn’t sent and the cell is edited instead. You can use this method to implement features such as sorting records according to the column that was double-clicked. See also clickedRow which you can use to determine if a row was clicked rather than the column heading.
For the method to have any effect, the receiver’s action and target must be set to the class in which the selector is declared. See Action Messages for additional information on action messages.
– setAction: (NSControl)– setTarget: (NSControl)– doubleActionNSTableView.hSets the feedback style displayed when the user drags over the table view.
- (void)setDraggingDestinationFeedbackStyle:(NSTableViewDraggingDestinationFeedbackStyle)style
The dragging feedback style. See “NSTableViewDraggingDestinationFeedbackStyle” for the possible values.
NSTableView.hSets the default operation mask returned by draggingSourceOperationMaskForLocal: to mask.
- (void)setDraggingSourceOperationMask:(NSDragOperation)mask forLocal:(BOOL)isLocal
If isLocal is YES then mask applies when the destination object is in the same application. If isLocal is NO then mask applies when the destination object in an application outside the receiver's application. NSTableView will archive the operation mask you set for each isLocal setting.
NSTableView.hUsed if you wish to “retarget” the proposed drop.
- (void)setDropRow:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation
To specify a drop on the second row, one would specify row as 1, and operation as NSTableViewDropOn. To specify a drop below the last row, one would specify row as [self numberOfRows] and operation as NSTableViewDropAbove. Passing a value of –1 for row, and NSTableViewDropOn as the operation causes the entire table view to be highlighted rather than a specific row. This is useful if the data displayed by the receiver does not allow the user to drop items at a specific row location.
NSTableView.hSets the currently focused column to the specified index.
- (void)setFocusedColumn:(NSInteger)focusedColumn
The index of the column to focus, or -1 if there should be no focused column.
This method will redisplay the old previously focusedColumn and the newly focusedColumn, if required.
The focused column has a focus ring drawn around the selectedRow that intersects with the focusedColumn.
You should not override this method.
NSTableView.hSets the color used to draw grid lines to a given color.
- (void)setGridColor:(NSColor *)aColor
The color to use to draw grid lines.
The default color is gray.
NSTableView.hSets the grid style mask to specify if no grid lines, vertical grid lines, or horizontal grid lines should be displayed.
- (void)setGridStyleMask:(NSUInteger)gridType
The grid style mask. Possible values for gridType are described in “Grid styles.”
NSTableView.hSets the receiver’s header view to a given header view.
- (void)setHeaderView:(NSTableHeaderView *)aHeaderView
The header view for the receiver.
If aHeaderView is nil, the current header view is removed.
NSTableView.hSets aTableColumn to be the currently highlighted column header.
- (void)setHighlightedTableColumn:(NSTableColumn *)aTableColumn
NSTableView.hSets the indicator image of aTableColumn to anImage.
- (void)setIndicatorImage:(NSImage *)anImage inTableColumn:(NSTableColumn *)aTableColumn
anImage is retained and released by the table view as appropriate.
The default sorting order indicators are available as named NSImage objects. These images are accessed using [NSImage imageNamed:] passing either @"NSAscendingSortIndicator" (the "^" icon), and @"NSDescendingSortIndicator" (the "v" icon).
NSTableView.hSets the width and height between cells to those in a given NSSize struct.
- (void)setIntercellSpacing:(NSSize)aSize
An NSSize struct that defines the width and height between cells in the receiver.
The receiver redisplays after the new value is set.
The default intercell spacing is (3.0, 2.0).
Table views normally have a 1 pixel separation between consecutively selected rows or columns. An intercell spacing of (1.0, 1.0) or greater is required if you want this separation. An intercell spacing of (0.0, 0.0) forces there to be no separation between consecutive selections.
NSTableView.hSets the height for rows to a given value.
- (void)setRowHeight:(CGFloat)rowHeight
The height for rows.
After the height is set, this method invokes tile.
NSTableView.hSets the selection highlight style used by the receiver to indicate row and column selection.
- (void)setSelectionHighlightStyle:(NSTableViewSelectionHighlightStyle)selectionHighlightStyle
The selection highlight style to use to indicate row and column selection. See “Selection Styles” for the possible values.
Setting the selection highlight style to NSTableViewSelectionHighlightStyleSourceList causes the receiver to draw its background using the source list style.
NSTableView.hSets the receiver’s sort descriptors to the NSSortDescriptor objects in array.
- (void)setSortDescriptors:(NSArray *)array
A table column is considered sortable if it has a sort descriptor that specifies the sorting direction, a key to sort by, and a selector defining how to sort. The array of sort descriptors is archived. Sort descriptors persist along with other column information if an autosave name is set.
NSTableView.hSets whether the receiver uses the standard alternating row colors for its background.
- (void)setUsesAlternatingRowBackgroundColors:(BOOL)useAlternatingRowColors
YES to specify standard alternating row colors for the background, NO to specify a solid color.
NSTableView.hSets whether vertical motion is treated as a drag or selection change to flag.
- (void)setVerticalMotionCanBeginDrag:(BOOL)flag
If flag is NO then vertical motion will not start a drag. The default is YES.
Note that horizontal motion is always a valid motion to begin a drag. Most often, you would want to disable vertical dragging when it’s expected that horizontal dragging is the natural motion.
NSTableView.hReturns whether the fully cell at the specified row and column can be made the focused cell or not.
- (BOOL)shouldFocusCell:(NSCell *)cell atColumn:(NSInteger)column row:(NSInteger)row
The prepared cell to be focused upon.
The column of the cell.
The row of the cell.
YES if the cell can be made the focused cell, otherwise NO.
By default, only cells that are enabled can be focused. In addition, if the cell is an NSTextFieldCell, it will can only be focused if it is selectable or editable, and the table view delegate responds YES to -tableView:shouldEditTableColumn:row:. Subclasses can override this to further control what cells can and cannot be made focused.
NSTableView.hResizes the last column if there’s room so the receiver fits exactly within its enclosing clip view.
- (void)sizeLastColumnToFit
– setAutoresizesAllColumnsToFit:– minWidth (NSTableColumn)– maxWidth (NSTableColumn)NSTableView.hChanges the width of columns in the receiver so all columns are visible.
- (void)sizeToFit
All columns are resized to the same size, up to a column's maximum size. This method then invokes tile.
NSTableView.hReturns the receiver’s sort descriptors.
- (NSArray *)sortDescriptors
NSTableView.hReturns an array containing the the NSTableColumn objects in the receiver.
- (NSArray *)tableColumns
An array containing the the NSTableColumn objects in the receiver.
The array returned by tableColumns contains all receiver’s columns, including those that are hidden.
NSTableView.hReturns the NSTableColumn object for the first column whose identifier is equal to a given object.
- (NSTableColumn *)tableColumnWithIdentifier:(id)anObject
A column identifier.
The NSTableColumn object for the first column whose identifier is equal to anObject, as compared using isEqual:, or nil if no columns are found with the specified identifier.
NSTableView.hPosts an NSControlTextDidBeginEditingNotification to the default notification center.
- (void)textDidBeginEditing:(NSNotification *)aNotification
The notification posted by the field editor; see the NSText class specifications for more information on this text delegate method.
For more details, see the NSControl class specification.
NSTableView.hSends textDidChange: to the edited cell and posts an NSControlTextDidChangeNotification to the default notification center.
- (void)textDidChange:(NSNotification *)aNotification
The notification posted by the field editor.
See the NSText class specification for more information on this text delegate method. For additional details, see the NSControl class specification.
NSTableView.hUpdates the data source based on the newly edited value and selects another cell for editing if possible according to the character that ended editing (Return, Tab, Backtab).
- (void)textDidEndEditing:(NSNotification *)aNotification
aNotification is the NSNotification posted by the field editor; see the NSText class specification for more information on this text delegate method.
NSTableView.hQueries the delegate using control:textShouldBeginEditing:, returning the delegate’s response, or simply returning YES to allow editing of textObject if the delegate doesn’t respond to that method.
- (BOOL)textShouldBeginEditing:(NSText *)textObject
See the NSText class specification for more information on this text delegate method.
NSTableView.hValidates the textObject cell being edited and queries the delegate using control:textShouldEndEditing:, returning the delegate’s response if it responds to that method.
- (BOOL)textShouldEndEditing:(NSText *)textObject
If it doesn’t, it returns YES if the cell’s new value is valid and NO if it isn’t. See the NSText class specification for more information on this text delegate method.
NSTableView.hProperly sizes the receiver and its header view and marks it as needing display.
- (void)tile
Also resets cursor rectangles for the header view and line scroll amounts for the NSScrollView object.
– setNeedsDisplay: (NSView)NSTableView.hReturns a Boolean value that indicates whether the receiver uses the standard alternating row colors for its background.
- (BOOL)usesAlternatingRowBackgroundColors
YES if the receiver uses standard alternating row colors for the background, NO if it uses a solid color.
NSTableView.hReturns whether vertical motion is treated as a drag or selection change.
- (BOOL)verticalMotionCanBeginDrag
NO means that vertical motion will not start a drag. Note that horizontal motion is always a valid motion to begin a drag.
NSTableView.hThese constants specify the drag styles displayed by the table view. They’re used by the draggingDestinationFeedbackStyle and setDraggingDestinationFeedbackStyle:
enum {
NSTableViewDraggingDestinationFeedbackStyleNone = -1,
NSTableViewDraggingDestinationFeedbackStyleRegular = 0,
NSTableViewDraggingDestinationFeedbackStyleSourceList = 1,
};
#endif
typedef NSInteger NSTableViewDraggingDestinationFeedbackStyle;
NSTableViewDraggingDestinationFeedbackStyleNoneProvides no feedback when the user drags over the table view. This option exists to allow subclasses to implement their dragging destination highlighting, or to make it not show anything all.
Available in Mac OS X v10.6 and later.
Declared in NSTableView.h.
NSTableViewDraggingDestinationFeedbackStyleRegularDraws a solid round-rect background on drop target rows, and an insertion marker between rows. This style should be used in most cases.
Available in Mac OS X v10.6 and later.
Declared in NSTableView.h.
NSTableViewDraggingDestinationFeedbackStyleSourceListDraws an outline on drop target rows, and an insertion marker between rows. This style will automatically be set for source lists when the table’s setSelectionHighlightStyle: is set to NSTableViewSelectionHighlightStyleSourceList. This is the standard look for Source Lists, but may be used in other areas as needed.
Available in Mac OS X v10.6 and later.
Declared in NSTableView.h.
NSTableView defines these constants to specify drop operations.
enum {
NSTableViewDropOn,
NSTableViewDropAbove
};
typedef NSUInteger NSTableViewDropOperation;
NSTableViewDropOnSpecifies that the drop should occur on the specified row.
Available in Mac OS X v10.0 and later.
Declared in NSTableView.h.
NSTableViewDropAboveSpecifies that the drop should occur above the specified row.
Available in Mac OS X v10.0 and later.
Declared in NSTableView.h.
For example, given a table with n rows (numbered with row 0 at the top visually), a row of n–1 and operation of NSTableViewDropOn would specify a drop on the last row. To specify a drop below the last row, you use a row of n and NSTableViewDropAbove for the operation.
NSTableView.hNSTableView defines these constants to specify grid styles. These constants are used by gridStyleMask and setGridStyleMask:. The mask can be either NSTableViewGridNone or it can contain either or both of the other options combined using the C bitwise OR operator.
enum {
NSTableViewGridNone = 0,
NSTableViewSolidVerticalGridLineMask = 1 << 0,
NSTableViewSolidHorizontalGridLineMask = 1 << 1
};
NSTableViewGridNoneSpecifies that no grid lines should be displayed.
Available in Mac OS X v10.3 and later.
Declared in NSTableView.h.
NSTableViewSolidVerticalGridLineMaskSpecifies that vertical grid lines should be displayed.
Available in Mac OS X v10.3 and later.
Declared in NSTableView.h.
NSTableViewSolidHorizontalGridLineMaskSpecifies that horizontal grid lines should be displayed.
Available in Mac OS X v10.3 and later.
Declared in NSTableView.h.
The following constants specify the autoresizing styles. These constants are used by columnAutoresizingStyle and setColumnAutoresizingStyle:.
enum {
NSTableViewNoColumnAutoresizing = 0,
NSTableViewUniformColumnAutoresizingStyle,
NSTableViewSequentialColumnAutoresizingStyle,
NSTableViewReverseSequentialColumnAutoresizingStyle,
NSTableViewLastColumnOnlyAutoresizingStyle,
NSTableViewFirstColumnOnlyAutoresizingStyle
};
typedef NSUInteger NSTableViewColumnAutoresizingStyle;
NSTableViewNoColumnAutoresizingDisable table column autoresizing.
Available in Mac OS X v10.4 and later.
Declared in NSTableView.h.
NSTableViewUniformColumnAutoresizingStyleAutoresize all columns by distributing space equally, simultaneously.
Available in Mac OS X v10.4 and later.
Declared in NSTableView.h.
NSTableViewSequentialColumnAutoresizingStyleAutoresize each table column sequentially, from the last auto-resizable column to the first auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size.
Available in Mac OS X v10.4 and later.
Declared in NSTableView.h.
NSTableViewReverseSequentialColumnAutoresizingStyleAutoresize each table column sequentially, from the first auto-resizable column to the last auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size.
Available in Mac OS X v10.4 and later.
Declared in NSTableView.h.
NSTableViewLastColumnOnlyAutoresizingStyleAutoresize only the last table column.
When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead.
Available in Mac OS X v10.4 and later.
Declared in NSTableView.h.
NSTableViewFirstColumnOnlyAutoresizingStyleAutoresize only the first table column.
When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead.
Available in Mac OS X v10.4 and later.
Declared in NSTableView.h.
The following constants specify the selection highlight styles. These constants are used by selectionHighlightStyle and setSelectionHighlightStyle:.
enum {
NSTableViewSelectionHighlightStyleNone = -1,
NSTableViewSelectionHighlightStyleRegular = 0,
NSTableViewSelectionHighlightStyleSourceList = 1,
};
typedef NSInteger NSTableViewSelectionHighlightStyle;
NSTableViewSelectionHighlightStyleNoneDisplays no highlight style at all.
Available in Mac OS X v10.6 and later.
Declared in NSTableView.h.
NSTableViewSelectionHighlightStyleRegularThe regular highlight style of NSTableView. On Mac OS X v10.5 a light blue (returned by sending NSColor a alternateSelectedControlColor message) or light gray color (returned by sending NSColor a secondarySelectedControlColor message).
Available in Mac OS X v10.5 and later.
Declared in NSTableView.h.
NSTableViewSelectionHighlightStyleSourceListThe source list style of NSTableView. On 10.5, a light blue gradient is used to highlight selected rows.
drawsBackground must set the value to NO. Otherwise, the cells will draw over the tableview’s highlighting.Available in Mac OS X v10.5 and later.
Declared in NSTableView.h.
Posted whenever a column is moved by user action in an NSTableView object. The notification object is the table view in which a column moved. The userInfo dictionary contains the following information:
Key | Value |
|---|---|
| An |
| An |
NSTableView.hPosted whenever a column is resized in an NSTableView object. The notification object is the table view in which a column was resized. The userInfo dictionary contains the following information:
Key | Value |
|---|---|
| The column that was resized. |
| An NSNumber containing the integer value of the column’s original width. |
NSTableView.hPosted after an NSTableView object's selection changes. The notification object is the table view whose selection changed. This notification does not contain a userInfo dictionary.
NSTableView.hPosted as an NSTableView object's selection changes (while the mouse button is still down). The notification object is the table view whose selection is changing. This notification does not contain a userInfo dictionary.
NSTableView.hLast updated: 2009-05-29