NSTableView Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Declared in | NSTableView.h |
| Companion guides | |
Overview
An NSTableView object displays data for a set of related records, with rows representing individual records and columns representing the attributes of those records.
Table views are displayed in scroll views. Beginning with OS X v 10.7 NSView instances (most commonly NSTableCellView instances or a subclass) are supported for rows and columns. Alternatively, NSCell subclass instances can be used for each row and column item.
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 NSTableViewDelegate Protocol, which declares methods that return views for rows and columns as well as enable selectable cell editing, custom tracking, custom views and cells for individual columns and rows, and selection control. Additional functionality is also available through the use of delegate methods.
See the NSTableViewDataSource protocol, declares the methods that an NSTableView object uses to provide and access the contents of its data source object.
Subclassing
Subclassing of the NSTableView class is rarely necessary. Instead, consider customizing the table view using your delegate class (conforming to the NSTableViewDelegate Protocol protocol) or the datasource class (conforming to the NSTableViewDataSource protocol), or by subclassing one of the following subcomponents: cells (when using cell based table views), row cell view or row view (when using view based table views), table column, or table column header classes.
Tasks
Creating the Displayed Views
Setting the Data Source
Loading Data
Using Views for Row and Column Content
-
– beginUpdates -
– endUpdates -
– columnForView: -
– moveRowAtIndex:toIndex: -
– insertRowsAtIndexes:withAnimation: -
– removeRowsAtIndexes:withAnimation: -
– rowForView:
View-based Table Nib Registration
Target-action Behavior
Configuring Behavior
-
– setAllowsColumnReordering: -
– allowsColumnReordering -
– setAllowsColumnResizing: -
– allowsColumnResizing -
– setAllowsMultipleSelection: -
– allowsMultipleSelection -
– setAllowsEmptySelection: -
– allowsEmptySelection -
– setAllowsColumnSelection: -
– allowsColumnSelection
Setting Display Attributes
-
– setIntercellSpacing: -
– intercellSpacing -
– setRowHeight: -
– rowHeight -
– setBackgroundColor: -
– backgroundColor -
– setUsesAlternatingRowBackgroundColors: -
– usesAlternatingRowBackgroundColors -
– selectionHighlightStyle -
– setSelectionHighlightStyle: -
– setGridColor: -
– gridColor -
– setGridStyleMask: -
– gridStyleMask -
– indicatorImageInTableColumn: -
– setIndicatorImage:inTableColumn:
Getting and Setting Row Size Styles
Column Management
-
– addTableColumn: -
– removeTableColumn: -
– moveColumn:toColumn: -
– tableColumns -
– columnWithIdentifier: -
– tableColumnWithIdentifier:
Selecting Columns and Rows
-
– selectColumnIndexes:byExtendingSelection: -
– selectedColumn -
– selectedColumnIndexes -
– deselectColumn: -
– numberOfSelectedColumns -
– isColumnSelected: -
– selectRowIndexes:byExtendingSelection: -
– selectedRow -
– selectedRowIndexes -
– deselectRow: -
– numberOfSelectedRows -
– isRowSelected: -
– selectAll: -
– deselectAll:
Enumerating Table Rows
Managing Type Select
Getting and Setting Column Focus
Table Dimensions
Displaying Cell
Getting and Setting Floating Rows
Editing Cells
Setting Auxiliary Views
Layout Support
-
– rectOfColumn: -
– rectOfRow: -
– rowsInRect: -
– columnIndexesInRect: -
– columnAtPoint: -
– rowAtPoint: -
– frameOfCellAtColumn:row: -
– columnAutoresizingStyle -
– setColumnAutoresizingStyle: -
– sizeLastColumnToFit -
– noteNumberOfRowsChanged -
– tile -
– sizeToFit -
– noteHeightOfRowsWithIndexesChanged: -
– columnsInRect:Deprecated in OS X v10.5
Drawing
-
– drawRow:clipRect: -
– drawGridInClipRect: -
– highlightSelectionInClipRect: -
– drawBackgroundInClipRect:
Scrolling
Table Column State Persistence
Setting the Delegate
Highlightable Column Headers
Dragging
-
– dragImageForRowsWithIndexes:tableColumns:event:offset: -
– canDragRowsWithIndexes:atPoint: -
– setDraggingSourceOperationMask:forLocal: -
– setVerticalMotionCanBeginDrag: -
– verticalMotionCanBeginDrag -
– draggingDestinationFeedbackStyle -
– setDraggingDestinationFeedbackStyle: -
– setDropRow:dropOperation:
Sorting
Text Delegate Methods
-
– textShouldBeginEditing: -
– textDidBeginEditing: -
– textDidChange: -
– textShouldEndEditing: -
– textDidEndEditing:
Deprecated Methods
-
– drawsGridDeprecated in OS X v10.3 -
– selectColumn:byExtendingSelection:Deprecated in OS X v10.3 -
– selectedColumnEnumeratorDeprecated in OS X v10.3 -
– selectedRowEnumeratorDeprecated in OS X v10.3 -
– selectRow:byExtendingSelection:Deprecated in OS X v10.3 -
– setDrawsGrid:Deprecated in OS X v10.3 -
– autoresizesAllColumnsToFitDeprecated in OS X v10.4 -
– dragImageForRows:event:dragImageOffset:Deprecated in OS X v10.4 -
– setAutoresizesAllColumnsToFit:Deprecated in OS X v10.4 -
– tableView:writeRows:toPasteboard:delegate method Deprecated in OS X v10.4
Instance Methods
addTableColumn:
Adds a given column as the last column of the receiver.
Parameters
- aColumn
The column to add to the receiver.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hallowsColumnReordering
Returns a Boolean value that indicates whether the receiver allows the user to rearrange columns by dragging their headers.
Discussion
The default is YES. You can rearrange columns programmatically regardless of this setting.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hallowsColumnResizing
Returns a Boolean value that indicates whether the receiver allows the user to resize columns by dragging between their headers.
Return Value
YES if the receiver allows the user to resize columns by dragging between their headers, otherwise NO.
Discussion
The default is YES. You can resize columns programmatically regardless of this setting.
Availability
- Available in OS X v10.0 and later.
See Also
-
setWidth:(NSTableColumn) -
– setAllowsColumnResizing:
Declared In
NSTableView.hallowsColumnSelection
Returns a Boolean value that indicates whether the receiver allows the user to select columns by clicking their headers.
Return Value
YES if the receiver allows the user to select columns by clicking their headers, otherwise NO.
Discussion
The default is NO. You can select columns programmatically regardless of this setting.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hallowsEmptySelection
Returns a Boolean value that indicates whether the receiver allows the user to select zero columns or rows.
Discussion
The default is YES.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hallowsMultipleSelection
Returns a Boolean value that indicates whether the receiver allows the user to select more than one column or row at a time.
Return Value
YES if the receiver allows the user to select more than one column or row at a time, otherwise NO.
Discussion
The default is NO. You can select multiple columns or rows programmatically regardless of this setting.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hallowsTypeSelect
Returns a Boolean value that indicates whether the receiver allows the user to type characters to select rows.
Return Value
YES if the receiver allows type selection, otherwise NO.
Discussion
The default value is YES.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTableView.hautosaveName
Returns the name under which table information is automatically saved.
Return Value
The name under which table information is automatically saved. If no name has been set, returns nil.
Discussion
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 will only save the table information if autosaveTableColumns returns YES.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hautosaveTableColumns
Returns a Boolean value that indicates whether the order and width of the receiver’s columns are automatically saved.
Return Value
YES if the table column order and width should be automatically saved, otherwise NO.
Discussion
The table information is saved separately for each user and application.
The following information is saved: the table column width, the table column order, any applied sort descriptors, and the table column hidden state (on OS X v 10.5 and later).
Note that if autosaveName returns nil, this setting is ignored and table information isn’t saved.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hbackgroundColor
Returns the color used to draw the background of the receiver.
Return Value
The color used to draw the background of the receiver.
Discussion
The default background color is light gray.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hbeginUpdates
Begins a group of updates for the table view.
Discussion
For View-based table views multiple row changes (insertions, deletions, and moves) will be animated simultaneously by surrounding calls to those method calls using the methods beginUpdates and endUpdates. These methods are nestable.
The selected rows are maintained during the series of insertions, deletions, moves and scrolling. If a selected row is deleted, a selection changed notification will occur after removeRowsAtIndexes:withAnimation: is called.
It is not necessary to call beginUpdates and endUpdates if only one insertion, deletion, or move is occurring and the receiver is a row based table view. When using a cell based table view you must surround any insertion, deletion, or move in an update block for animations to occur.
The main reason for doing a batch update of changes to a table view is to avoid having the table animate unnecessarily.
Note that these methods should be called to reflect changes in your model; they do not make any underlying model changes.
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTableView.hcanDragRowsWithIndexes:atPoint:
Returns whether the receiver allows dragging the rows at with the drag initiated at the specified point.
Parameters
- rowIndexes
The row indexes to drag.
- mouseDownPoint
The location where the drag was initiated.
Return Value
Return NO to disallow the drag.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTableView.hclickedColumn
Returns the index of the column the user clicked to trigger an action message.
Return Value
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 or if the user has clicked in a row that is a group separator.
Discussion
The return value of this method is meaningful only in the target’s implementation of the action or double-action method.
Availability
- Available in OS X v10.0 and later.
See Also
-
– clickedRow -
setAction:(NSControl) -
– setDoubleAction:
Declared In
NSTableView.hclickedRow
Returns the index of the row the user clicked to trigger an action message.
Return Value
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.
Discussion
The return value of this method is meaningful only in the target’s implementation of the action or double-action method.
Availability
- Available in OS X v10.0 and later.
See Also
-
– clickedColumn -
setAction:(NSControl) -
– setDoubleAction:
Declared In
NSTableView.hcolumnAtPoint:
Returns the index of the column a given point lies in.
Parameters
- aPoint
A point in the coordinate system of the receiver.
Return Value
The index of the column aPoint lies in, or –1 if aPoint lies outside the receiver’s bounds.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hcolumnAutoresizingStyle
Returns the receiver’s column autoresizing style.
Return Value
The receiver’s column autoresizing style. For possible values, see rowSizeStyle.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTableView.hcolumnForView:
Returns the column index for the specified view.
Parameters
- view
The row view.
Return Value
The index of the column in the tableColumns array. Returns -1 if the view is not an instance or subclass of NSTableRowView.
Discussion
This method typically used in the action method of an NSButton (or NSControl) to find out what row (and column) the action should be performed on.
The implementation is O(n) where n is the number of visible rows, so this method should generally not be called within a loop.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hcolumnIndexesInRect:
Returns the indexes of the receiver’s columns that intersect the specified rectangle.
Parameters
- rect
The rectangle in the receiver’s coordinate system to test for column enclosure.
Return Value
New NSIndexSet object containing the indexes of the receiver’s columns that intersect with rect.
Discussion
Columns that return YES for the NSTableColumn method isHidden are excluded from the results.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTableView.hcolumnWithIdentifier:
Returns the index of the first column in the receiver whose identifier is equal to a given identifier.
Parameters
- anObject
A column identifier.
Return Value
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hcornerView
Returns the view used to draw the area to the right of the column headers and above the vertical scroller of the enclosing scroll view.
Return Value
The view used to draw the area to the right of the column headers and above the vertical scroller of the enclosing NSScrollView object.
Discussion
This is by default a simple view that merely fills in its frame, but you can replace it with a custom view using setCornerView:.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hdataSource
Returns the object that provides the data displayed by the table view.
Return Value
The object that provides the data displayed by the table view.
Discussion
See “Populating View-Based Table Views Programmatically” and the NSTableViewDataSource protocol specification for more information.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setDataSource:
Declared In
NSTableView.hdelegate
Returns the receiver’s delegate.
Return Value
The receiver’s delegate.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hdeselectAll:
Deselects all selected rows or columns if empty selection is allowed; otherwise does nothing.
Parameters
- sender
Typically the object that sent the message.
Discussion
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:.
Availability
- Available in OS X v10.0 and later.
See Also
-
– allowsEmptySelection -
– selectAll: -
– selectColumn:byExtendingSelection: -
selectionShouldChangeInTableView:(NSTableViewDelegate)
Declared In
NSTableView.hdeselectColumn:
Deselects the column at a given index if it’s selected.
Parameters
- columnIndex
The index of the column to deselect.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hdeselectRow:
Deselects the row at a given index if it’s selected.
Parameters
- rowIndex
The index of the row to deselect.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hdoubleAction
Returns the message sent to the target when the user double-clicks a cell or column header.
Return Value
The message the table view sends to its target when the user double-clicks a cell or a column header.
Availability
- Available in OS X v10.0 and later.
See Also
-
target(NSControl) -
– setDoubleAction:
Declared In
NSTableView.hdraggingDestinationFeedbackStyle
Returns the feedback style displayed when the user drags over the table view.
Return Value
The dragging feedback style. See NSTableViewDraggingDestinationFeedbackStyle for the possible values.
Discussion
The default value is NSTableViewDraggingDestinationFeedbackStyleRegular.
However, when the method setSelectionHighlightStyle: has a value of NSTableViewSelectionHighlightStyleSourceList is called the draggingDestinationFeedbackStyle will also be changed to NSTableViewSelectionHighlightStyleSourceList.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTableView.hdragImageForRowsWithIndexes:tableColumns:event:offset:
Computes and returns an image to use for dragging.
Parameters
- dragRows
An index set containing the row indexes that should be in the image..
- tableColumns
An array of table columns that should be in the image..
- dragEvent
The event that initiated the drag.
- dragImageOffset
An in/out parameter specifying the offset of the cursor in the image, the default value is
NSZeroPoint. ReturningNSZeroPointcauses the cursor to be centered.
Return Value
An NSImage containing a custom image for the specified rows and columns participating in the drag.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTableView.hdrawBackgroundInClipRect:
Draws the background of the table view in the clip rect specified by the rectangle.
Parameters
- clipRect
The rectangle, in the table view’s coordinate system.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTableView.hdrawGridInClipRect:
Draws the grid lines within aRect, using the grid color set with setGridColor:.
Parameters
- aRect
The rectangle in the table view’s coordinate system.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hdrawRow:clipRect:
Draws the cells for the row at rowIndex in the columns that intersect clipRect.
Parameters
- rowIndex
The row index.
- clipRect
The intersecting rectangle.
Discussion
Cell-based table views can override this method to custom the drawing of the rows.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.heditColumn:row:withEvent:select:
Edits the cell at the specified column and row and rowIndex using the specified event and selection behavior.
Parameters
- columnIndex
The index of the column in the
tableColumnstableColumnsarray.- rowIndex
The row index.
- theEvent
The event.
- flag
YESif the enter contents should be selected, otherwiseNO.
Discussion
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 editWithFrame:inView:editor:delegate:event: or, if select is YES, 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 selectWithFrame:inView:editor:delegate:start:length: or an exception will be raised.
This method can be overridden to customize drawing for 'row' when using cell-based table views.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.heditedColumn
Returns the index of the column being edited.
Return Value
If sent during editColumn:row:withEvent:select:, the index of the column being edited; otherwise –1.
Discussion
The returned value will also be -1 if there is no editing session, or the currently edited row is a "full width" row.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.heditedRow
Returns the index of the row being edited.
Return Value
If sent during editColumn:row:withEvent:select:, the index of the row being edited; otherwise –1.
Discussion
This method is not applicable with View-based table views. Instead, subviews are responsible for editing.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.heffectiveRowSizeStyle
Returns the effective row size style for the table.
Return Value
The row size style for the table.
Discussion
If the rowSizeStyle is NSTableViewRowSizeStyleDefault, then this method returns the default size for this table.
The default size is currently set in the System Preferences by the user.s
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTableView.hendUpdates
Ends the group of updates for the table view.
Discussion
Ends the group of updates for the table view. This method, like beginUpdates, is nestable. See beginUpdates for details.
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTableView.henumerateAvailableRowViewsUsingBlock:
Allows the enumeration of all the table rows that are known to the table view.
Parameters
- handler
The Block to apply to elements in the set.
The Block takes two arguments:
- rowView
The view for the row.
- row
The index of the row
Discussion
The enumeration includes all views in the visibleRect, however, it may also include ones that are "in flight" due to animations or other attributes of the table.
It is preferred to use this method to efficiently make changes over all views that exist in the table.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hfloatsGroupRows
Returns whether the table view will draw grouped rows as floating.
Return Value
The group float row state.
Discussion
Group rows can optionally appear to float. Group rows are rows that return YES when the the delegate method tableView:isGroupRow: is invoked. The default value is YES.
This property is encoded and decoded in the nib.
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTableView.hfocusedColumn
Returns the currently focused column.
Return Value
The index of the column, or -1 if there is no focused column
Discussion
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.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTableView.hframeOfCellAtColumn:row:
Returns a rectangle locating the cell that lies at the intersection of columnIndex and rowIndex.
Parameters
- columnIndex
The index of the column containing the cell whose rectangle you want.
- rowIndex
The index of the row containing the cell whose rectangle you want.
Return Value
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.
Discussion
You can use this method to update a single cell more efficiently than sending the table view a reloadData message using reloadDataForRowIndexes:columnIndexes:
The result of this method is used in a drawWithFrame:inView: message to the table column's data cell. You can subclass and override this method to customize the frame of a particular cell. However, never return a frame larger than the default implementation returns.
The default frame is computed to have a height equal to the rectOfRow: for rowIndex, minus the half intercellSpacing height on the top and half on the bottom. The width of frame is equal to the with of the table column minus half the intercellSpacing width on the left, and half on the right.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hgridColor
Returns the color used to draw grid lines.
Return Value
The color used to draw grid lines.
Discussion
The default color is gray.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hgridStyleMask
Returns the receiver’s grid style mask.
Return Value
The receiver’s grid style mask. Possible return values are described in “Grid styles.”
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTableView.hheaderView
Returns the NSTableHeaderView object used to draw headers over columns.
Return Value
The NSTableHeaderView object used to draw headers over columns, or nil if the receiver has no header view
Discussion
See the NSTableHeaderView class specification for more information.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hhighlightedTableColumn
Returns the table column highlighted in the receiver.
Return Value
The table column highlighted in the receiver.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hhighlightSelectionInClipRect:
Highlights the region of the receiver in the specified rectangle.
Parameters
- clipRect
The rectangle, in the table view view’s coordinate system.
Discussion
This method is invoked before drawRow:clipRect:.
Cell-based table views can override this method to change the manner in which they highlight selections.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hindicatorImageInTableColumn:
Returns the indicator image of a given table column.
Parameters
- aTableColumn
A table column in the receiver.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hinsertRowsAtIndexes:withAnimation:
Inserts the rows using the specified animation.
Parameters
- indexes
The final positions of the new rows to be inserted.
- animationOptions
The animation displayed during the insert. See
NSTableViewAnimationOptionsfor the possible values that can be combined using the C bitwise OR operator.
Discussion
The numberOfRows in the table view will automatically be increased by the count of indexes.
Calling this method multiple times within the same beginUpdates and endUpdates block is allowed, and changes are processed incrementally.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hintercellSpacing
Returns the horizontal and vertical spacing between cells.
Return Value
The horizontal and vertical spacing between cells.
Discussion
The default spacing is (3.0, 2.0).
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hisColumnSelected:
Returns a Boolean value that indicates whether the column at a given index is selected.
Parameters
- columnIndex
The index of the column to test.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hisRowSelected:
Returns a Boolean value that indicates whether the row at a given index is selected.
Parameters
- rowIndex
The index of the row to test.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hmakeViewWithIdentifier:owner:
Returns an autoreleased view with the specified identifier.
Parameters
- identifier
The view identifier. Must not be
nil.- owner
The owner of the NIB that may be loaded and instituted to create a new view with the particular identifier.
Return Value
An autoreleased view for the row.
Discussion
Typically identifier is associated with an external NIB in Interface Builder and the table view will automatically instantiate the NIB with the provided owner. The owner of the NIB that may be loaded and instantiated to create a new view with the particular identifier and is typically the table view’s delegate. The owner is useful in setting up outlets and target and actions from the view.
This method will typically be called by the delegate in tableView:viewForTableColumn:row:, but it can also be overridden to provide custom views for the identifier. This method may also return a reused view with the same identifier that was no longer available on screen.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hmoveColumn:toColumn:
Moves the column and heading at a given index to a new given index.
Parameters
- columnIndex
The current index of the column to move.
- newIndex
The new index for the moved column.
Discussion
This method posts NSTableViewColumnDidMoveNotification to the default notification center.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hmoveRowAtIndex:toIndex:
Moves the specified row to the new row location using animation.
Parameters
- oldIndex
Initial row index.
- newIndex
New row index.
Discussion
This is similar to removing a row at oldIndex and inserting it back at newIndex, except the same view is used and simply has its position updated to the new location.
Changes happen incrementally as they are sent to the table; so as soon as this method is called the row can be considered moved. However the underlying view will not be moved, until endUpdates has been called.
This method can be called multiple times within the same beginUpdates and endUpdates block.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hnoteHeightOfRowsWithIndexesChanged:
Informs the receiver that the rows specified in indexSet have changed height.
Parameters
- indexSet
Index set of rows that have changed their height.
Discussion
If the delegate implements tableView:heightOfRow: this method immediately re-tiles the table view using the row heights the delegate provides.
For View-based tables, this method will animate. To turn off the animation, create an NSAnimationContext grouping and set the duration to 0. Then call this method and end the grouping.
For cell based tables, this method normally doesn't animate. However, it will animate if you call it inside a beginUpdates/endUpdates block.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTableView.hnoteNumberOfRowsChanged
Informs the receiver that the number of records in its data source has changed.
Discussion
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 NSTableViewDataSource protocol specification for information on the messages an NSTableView object sends to its data source.
Availability
- Available in OS X v10.0 and later.
See Also
-
– reloadData -
numberOfRowsInTableView:(NSTableViewDataSourceprotocol)
Declared In
NSTableView.hnumberOfColumns
Returns the number of columns in the receiver.
Return Value
The number of columns in the receiver.
Discussion
The value returned includes table columns that are currently hidden.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hnumberOfRows
Returns the number of rows in the receiver.
Return Value
The number of rows in the receiver.
Discussion
Typically you should not ask the table view how many rows it has; instead you should interrogate the table view's data source.
Availability
- Available in OS X v10.0 and later.
See Also
-
– numberOfColumns -
numberOfRowsInTableView:(NSTableViewDataSourceprotocol)
Declared In
NSTableView.hnumberOfSelectedColumns
Returns the number of selected columns.
Return Value
The number of selected columns.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hnumberOfSelectedRows
Returns the number of selected rows.
Return Value
The number of selected rows.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hperformClickOnCellAtColumn:row:
Performs a click action on the cell at the specified row and column.
Parameters
- column
The column of the cell.
- row
The row of the cell.
Discussion
Acquires the NSTableView, 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.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTableView.hpreparedCellAtColumn:row:
Returns the fully prepared cell that the receiver will use for drawing or processing of the specified row and column.
Parameters
- column
The index in the
tableColumnsarray to return the appropriate cell for.- row
The row index for which to return the appropriate cell.
Return Value
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.
Discussion
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.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTableView.hrectOfColumn:
Returns the rectangle containing the column at a given index.
Parameters
- columnIndex
The index of a column in the receiver.
Return Value
The rectangle containing the column at columnIndex. Returns NSZeroRect if columnIndex lies outside the range of valid column indices for the receiver.
Discussion
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]]; |
Availability
- Available in OS X v10.0 and later.
See Also
-
– frameOfCellAtColumn:row: -
– rectOfRow: -
headerRectOfColumn:(NSTableHeaderView)
Declared In
NSTableView.hrectOfRow:
Returns the rectangle containing the row at a given index.
Return Value
The rectangle containing the row at rowIndex. Returns NSZeroRect if rowIndex lies outside the range of valid row indices for the receiver.
Discussion
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]]; |
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hregisteredNibsByIdentifier
Returns a dictionary of all registered nibs for View-based table view identifiers.
Return Value
A dictionary containing the identifiers and associated nibs.
Discussion
The keys are the identifiers, and the value of each key is the NSNib instance that is registered.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSTableView.hregisterNib:forIdentifier:
Registers a nib for the identifier, so that View-based table views can use it to instantiate views.
Parameters
- nib
The nib containing the view.
- identifier
The identifier of the view to create.
Discussion
This method (or associates) nib with identifier so the table can instantiate views from it when a view with identifier is requested. This method is used when makeViewWithIdentifier:owner: is invoked, and there was no nib created at design time for this particular table view identifier. This allows dynamic loading of nibs that can be associated with the table.
To remove a previously associated nib for a given identifier, pass in nil for the nib value.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSTableView.hreloadData
Marks the table view as needing redisplay, so it will reload the data for visible cells and draw the new values.
Discussion
This method forces a 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 the NSView method setNeedsDisplayInRect:. If you just want to update the scroller, use noteNumberOfRowsChanged; if the height of a set of rows changes, use noteHeightOfRowsWithIndexesChanged:.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hreloadDataForRowIndexes:columnIndexes:
Reloads the data for only the specified rows and columns.
Parameters
- rowIndexes
The indexes of the rows to update.
- columnIndexes
The indexes of the columns to update.
Discussion
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: if a row height change is required.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTableView.hremoveRowsAtIndexes:withAnimation:
Removes the rows using the specified animation.
Parameters
- indexes
An index set containing the rows to remove.
- animationOptions
The animation displayed during the insert. See
NSTableViewAnimationOptionsfor the possible values that can be combined using the C bitwise OR operator.
Discussion
The row represented at indexes will be deleted from the table. The numberOfRows in the table view will automatically be decreased by the count of indexes.
The row indexes should be with respect to the current state displayed in the table view, and not the final state, since the rows do not exist in the final state.
Calling this method multiple times within the same beginUpdates and endUpdates block is allowed, and changes are processed incrementally.
Changes are processed incrementally as the insertRowsAtIndexes:withAnimation:, removeRowsAtIndexes:withAnimation:, and the moveRowAtIndex:toIndex: methods are called. It is acceptable to delete row 0 multiple times, as long as there is still a row available.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hremoveTableColumn:
Removes a given column from the receiver.
Parameters
- aTableColumn
The column to remove from the receiver.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hrowAtPoint:
Returns the index of the row a given point lies in.
Parameters
- aPoint
A point in the coordinate system of the receiver.
Return Value
The index of the row aPoint lies in, or –1 if aPoint lies outside the receiver’s bounds.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hrowForView:
Returns the index of the row for the specified view.
Parameters
- view
The view.
Return Value
The index of the row corresponding to the view. Returns -1 if the view is not an instance of, or a subview of NSTableRowView.
Discussion
This is typically needed in the action method for an NSButton (or NSControl) to find out what row (and column) the action should be performed on.
The implementation is O(n) where n is the number of visible rows, so this method should generally not be called within a loop.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hrowHeight
Returns the height of each row in the receiver.
Return Value
The height of each row in the receiver.
Discussion
The default row height is 16.0.
The rowHeight is only used if the table's rowSizeStyle is set to NSTableViewRowSizeStyleCustom.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hrowsInRect:
Returns a range of indices for the rows that lie wholly or partially within the vertical boundaries of a given rectangle.
Parameters
- aRect
A rectangle in the coordinate system of the receiver.
Return Value
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.
Discussion
The location of the range is the first such row’s index, and the length is the number of rows that lie in aRect.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hrowSizeStyle
Returns the row size used by the tableview: small, medium, large, or on a custom row by row basis.
Return Value
The row style style. See NSTableViewRowSizeStyle for the supported options.
Discussion
The row size style can be modified on a row by row basis by invoking the delegate method tableView:heightOfRow:, if implemented.
The rowSizeStyle defaults to NSTableViewRowSizeStyleCustom. NSTableViewRowSizeStyleCustom indicates to use the rowHeight of the table, instead of the pre-determined system values.
Generally, rowSizeStyle should always be NSTableViewRowSizeStyleCustom except for "source lists". To implement variable row heights, set the value to NSTableViewRowSizeStyleCustom and implement tableView:heightOfRow: in the delegate.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hrowViewAtRow:makeIfNecessary:
Returns a row view at the specified index, creating one if necessary.
Parameters
- row
The row index.
- makeIfNecessary
YESif a view is required,NOif you want to update properties on a view, if one is available.
Return Value
An instance of, or subclass of, NSTableRowView. Returning nil is also valid if makeIfNecessary is NO and the view did not exist.
Discussion
This method will first attempt to return a currently displayed view in the visible area. If there is no visible view, and makeIfNecessary is YES, a prepared temporary view is returned. If makeIfNecessary is NO, and the view is not visible, nil will be returned.
In general, makeIfNecessary should be YES if you require a resulting view, and NO if you only want to update properties on a view only if it is available (generally this means it is visible).
An exception will be thrown if row is not within the numberOfRows. The returned result should generally not be held onto for longer than the current run loop cycle. It is better to call rowViewAtRow:makeIfNecessary: whenever a view is required..
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTableView.hscrollColumnToVisible:
Scrolls the view so the specified column is visible.
Parameters
- columnIndex
The index of the column in the
tableColumnsarray.
Availability
- Available in OS X v10.0 and later.
See Also
-
– scrollRowToVisible: -
scrollToPoint:(NSClipView)
Declared In
NSTableView.hscrollRowToVisible:
Scrolls the view so the specified row is visible.
Parameters
- rowIndex
The row index.
Availability
- Available in OS X v10.0 and later.
See Also
-
– scrollColumnToVisible: -
scrollToPoint:(NSClipView)
Declared In
NSTableView.hselectAll:
Selects all rows or all columns, according to whether rows or columns were most recently selected.
Parameters
- sender
Typically the object that sent the message.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hselectColumnIndexes:byExtendingSelection:
Sets the column selection using indexes possibly extending the selection.
Parameters
- indexes
The indexes to select.
- extend
YESif the selection should be extended,NOif the current selection should be changed.
Discussion
Replaces the deprecated selectColumn:byExtendingSelection: method.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTableView.hselectedColumn
Returns the index of the last column selected or added to the selection.
Return Value
The index of the last column selected or added to the selection, or –1 if no column is selected.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hselectedColumnIndexes
Returns an index set containing the indexes of the selected columns.
Return Value
An index set containing the indexes of the selected columns.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTableView.hselectedRow
Returns the index of the last row selected or added to the selection.
Return Value
The index of the last row selected or added to the selection, or –1 if no row is selected.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hselectedRowIndexes
Returns an index set containing the indexes of the selected rows.
Return Value
An index set containing the indexes of the selected rows.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTableView.hselectionHighlightStyle
Returns the selection highlight style used by the receiver to indicate row and column selection.
Return Value
The selection highlight style used by the receiver to use to indicate row and column selection. See NSTableViewSelectionHighlightStyle for the possible values.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTableView.hselectRowIndexes:byExtendingSelection:
Sets the row selection using indexes extending the selection if specified..
Parameters
- indexes
The indexes to select.
- extend
YESif the selection should be extended,NOif the current selection should be changed.
Discussion
Replaces the deprecated selectRow:byExtendingSelection: method.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTableView.hsetAllowsColumnReordering:
Controls whether the user can drag column headers to reorder columns.
Discussion
The default is YES. You can rearrange columns programmatically regardless of this setting.
Availability
- Available in OS X v10.0 and later.
See Also
-
– moveColumn:toColumn: -
– allowsColumnReordering -
tableView:didDragTableColumn:(NSTableViewDelegate Protocol) -
tableView:shouldReorderColumn:toColumn:(NSTableViewDelegate Protocol)
Declared In
NSTableView.hsetAllowsColumnResizing:
Controls whether the user can resize columns by dragging between headers.
Discussion
The default is YES. You can resize columns programmatically regardless of this setting.
Availability
- Available in OS X v10.0 and later.
See Also
-
setWidth:(NSTableColumn) -
– allowsColumnResizing
Declared In
NSTableView.hsetAllowsColumnSelection:
Controls whether the user can select an entire column by clicking its header.
Discussion
The default is NO. You can select columns programmatically regardless of this setting.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hsetAllowsEmptySelection:
Controls whether the receiver allows zero rows or columns to be selected.
Discussion
The default is YES.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hsetAllowsMultipleSelection:
Controls whether the user can select more than one row or column at a time.
Discussion
The default is NO. You can select multiple columns or rows programmatically regardless of this setting.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetAllowsTypeSelect:
Sets whether the receiver allows the user to type characters to select rows.
Parameters
- value
YESif the receiver allows type selection, otherwiseNO.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTableView.hsetAutosaveName:
Sets the name under which table information is automatically saved to name.
Parameters
- name
The autosave name.
Discussion
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. Setting nil as the name value will attempt to remove any previously stored state from the user defaults.
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 will only save table information if setAutosaveTableColumns: is set to YES.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetAutosaveTableColumns:
Sets whether the order and width of this table view’s columns are automatically saved.
Parameters
- flag
YESif the order and width of this table view’s columns are automatically saved, otherwiseNO.
Discussion
If autosaveName returns nil, this setting is ignored and table information isn’t saved.
If flag is different from the current value, this method also reads in the saved information and sets the table options to match.
The following information is saved: the table column width, the table column order, any applied sort descriptors, and the table column hidden state (on OS X v 10.5 and later).
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetBackgroundColor:
Sets the receiver’s background color to a given color.
Parameters
- aColor
The background color for the receiver.
Availability
- Available in OS X v10.0 and later.
See Also
-
setNeedsDisplay:(NSView) -
– backgroundColor
Declared In
NSTableView.hsetColumnAutoresizingStyle:
Sets the column autoresizing style of the receiver to a given style.
Parameters
- style
The column autoresizing style for the receiver. For possible values, see rowSizeStyle.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTableView.hsetCornerView:
Sets the receiver’s corner view to a given view.
Parameters
- aView
The corner view for the receiver.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetDataSource:
Sets the receiver’s data source to a given object.
Parameters
- anObject
The data source for the receiver. The object must implement the appropriate methods of the
NSTableViewDataSourceprotocol.
Discussion
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 the delegate doesn’t respond to either numberOfRowsInTableView: or tableView:objectValueForTableColumn:row:.
Availability
- Available in OS X v10.0 and later.
See Also
-
– dataSource
Declared In
NSTableView.hsetDelegate:
Sets the receiver’s delegate to a given object.
Parameters
- anObject
The delegate for the receiver. The delegate must conform to the
NSTableViewDelegate Protocolprotocol.
Discussion
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”).
Setting the delegate will implicitly reload the table view.
Special Considerations
When you call the tableview’s setDelegate: method, the delegate is automatically registered for the following notifications with the following delegate methods:
The notification named
NSTableViewSelectionDidChangeNotificationis configured to notify the delegate’stableViewSelectionDidChange:.The notification named
NSTableViewSelectionDidChangeNotificationis configured to notify the delegate’stableViewColumnDidMove:.The notification named
NSTableViewColumnDidResizeNotificationis configured to notify the delegate’stableViewColumnDidResize:.The notification named
NSTableViewSelectionDidChangeNotificationis configured to notify the delegate’stableViewSelectionIsChanging:.
Setting the delegate to nil will cause these notifications to be disconnected. Rather than setting the delegate to nil and listening for notifications (and expecting NSTableView to still function correctly) you should instead implement the appropriate delegate method.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetDoubleAction:
Sets the message selector sent to the target when the user double-clicks a cell or column header.
Parameters
- aSelector
The message the table view sends to its target when the user double-clicks a cell or a column header.
Discussion
If the double action is set, double-clicking always invokes the selector. If the double action is not set, then the cell will edit after a delay.
The clickedRow and clickedColumn methods allow you to determine which row and column the double-click occurred in or if, rather than in a row, it was in a column heading.
Note that if the table view uses Cocoa bindings and the “Double Click Target” binding is bound, both messages are invoked on their respective targets. First the Cocoa binding message is sent, then the setDoubleAction: message.
Availability
- Available in OS X v10.0 and later.
See Also
-
setTarget:(NSControl) -
– doubleAction
Declared In
NSTableView.hsetDraggingDestinationFeedbackStyle:
Sets the feedback style displayed when the user drags over the table view.
Parameters
- style
The dragging feedback style. See
NSTableViewDraggingDestinationFeedbackStylefor the possible values.
Availability
- Available in OS X v10.6 and later.
See Also
Declared In
NSTableView.hsetDraggingSourceOperationMask:forLocal:
Sets the default operation mask returned by draggingSourceOperationMaskForLocal: to mask.
Parameters
- mask
The drag operation mask. See
NSDragOperationfor the supported values.- isLocal
YESif the destination is the same application, otherwiseNO. In either case the specified mask value is archived and used.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTableView.hsetDropRow:dropOperation:
Used if you wish to “retarget” the proposed drop.
Parameters
- row
The target row index.
- operation
The drop operation. Supported values are specified by
NSTableViewDropOperation.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hsetFloatsGroupRows:
Sets whether the table view will draw grouped rows as floating.
Parameters
- value
The group float state.
Discussion
Group rows can optionally appear to float. Group rows are rows that return YES when the the delegate method tableView:isGroupRow: is invoked. The default value is YES.
This property is encoded and decoded in the nib.
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTableView.hsetFocusedColumn:
Sets the currently focused column to the specified index.
Parameters
- focusedColumn
The index of the column to focus, or -1 if there should be no focused column.
Discussion
This method will redisplay the old previously removeRowsAtIndexes:withAnimation: and the newly removeRowsAtIndexes:withAnimation:, if required.
The focused column has a focus ring drawn around the selectedRowselectedRow that intersects with the removeRowsAtIndexes:withAnimation:.
You should not override this method.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTableView.hsetGridColor:
Sets the color used to draw grid lines to a given color.
Parameters
- aColor
The color to use to draw grid lines.
Discussion
The default color is gray.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hsetGridStyleMask:
Sets the grid style mask to specify if no grid lines, vertical grid lines, or horizontal grid lines should be displayed.
Parameters
- gridType
The grid style mask. Possible values for gridType are described in “Grid styles.”
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTableView.hsetHeaderView:
Sets the receiver’s header view to a given header view.
Parameters
- aHeaderView
The header view for the receiver.
Discussion
If aHeaderView is nil, the current header view is removed.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetHighlightedTableColumn:
Sets aTableColumn to be the currently highlighted column header.
Parameters
- aTableColumn
The table column to highlight.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetIndicatorImage:inTableColumn:
Sets the indicator image of the specified column.
Parameters
- anImage
The indicator image for the column.
- aTableColumn
The table column.
Discussion
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).
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetIntercellSpacing:
Sets the width and height between cells to those in a given NSSize struct.
Parameters
- aSize
An
NSSizestruct that defines the width and height between cells in the receiver.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetRowHeight:
Sets the height for rows to a given value.
Parameters
- rowHeight
The height for rows.
Discussion
After the height is set, this method invokes tile.
The rowHeight is only used if the table's rowSizeStyle is set to NSTableViewRowSizeStyleCustom.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hsetRowSizeStyle:
Sets the row size used by the tableview: small, medium, large, or on a custom row by row basis.
Parameters
- rowSizeStyle
The row style style. See NSTableViewRowSizeStyle for the supported options.
Discussion
If the row size style is NSTableViewRowSizeStyleCustom, it will use the rowHeight specified.
The row size style can be modified on a row by row basis by implanting the delegate method tableView:heightOfRow:.
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTableView.hsetSelectionHighlightStyle:
Sets the selection highlight style used by the receiver to indicate row and column selection.
Parameters
- selectionHighlightStyle
The selection highlight style to use to indicate row and column selection. See
NSTableViewSelectionHighlightStylefor the possible values.
Discussion
Setting the selection highlight style to Subclassing causes the receiver to draw its background using the source list style. It also sets the draggingDestinationFeedbackStyle to NSTableViewDraggingDestinationFeedbackStyleSourceList.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTableView.hsetSortDescriptors:
Sets the receiver’s sort descriptors.
Parameters
- array
An array of
NSSortDescriptorobjects.
Discussion
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.
Calling setSortDescriptors: may have the side effect of invoking the datasource method tableView:sortDescriptorsDidChange:.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTableView.hsetUsesAlternatingRowBackgroundColors:
Sets whether the receiver uses the standard alternating row colors for its background.
Parameters
- useAlternatingRowColors
YESto specify standard alternating row colors for the background,NOto specify a solid color.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTableView.hsetVerticalMotionCanBeginDrag:
Sets whether vertical motion is treated as a drag or selection change to flag.
Parameters
- flag
YESif a vertical drag motion can begin a drag, otherwiseNO.
Discussion
The default is YES. In this case a vertical drag will drag-select rows.
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hshouldFocusCell:atColumn:row:
Returns whether the fully cell at the specified row and column can be made the focused cell or not.
Parameters
- cell
The prepared cell to be focused upon.
- column
The column of the cell.
- row
The row of the cell.
Return Value
YES if the cell can be made the focused cell, otherwise NO.
Discussion
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.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTableView.hsizeLastColumnToFit
Resizes the last column if there’s room so the receiver fits exactly within its enclosing clip view.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setAutoresizesAllColumnsToFit: -
minWidth(NSTableColumn) -
maxWidth(NSTableColumn)
Declared In
NSTableView.hsizeToFit
Changes the width of columns in the receiver so all columns are visible.
Discussion
All columns are resized to the same size, up to a column's maximum size. This method then invokes tile.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTableView.hsortDescriptors
Returns the receiver’s sort descriptors.
Return Value
Returns the table view’s array of NSSortDescriptor objects.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTableView.htableColumns
Returns an array containing the the NSTableColumn objects in the receiver.
Return Value
An array containing the the NSTableColumn objects in the receiver.
Discussion
The array returned by tableColumns contains all receiver’s columns, including those that are hidden.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.htableColumnWithIdentifier:
Returns the NSTableColumn object for the first column whose identifier is equal to a given object.
Parameters
- anObject
A column identifier.
Return Value
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.htextDidBeginEditing:
Posts an NSControlTextDidBeginEditingNotification to the default notification center.
Parameters
- aNotification
The notification posted by the field editor; see the
NSTextclass specifications for more information on this text delegate method.
Discussion
For more details, see the NSControl class specification.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.htextDidChange:
Sends textDidChange: to the edited cell and posts an NSControlTextDidChangeNotification to the default notification center.
Parameters
- aNotification
The notification posted by the field editor.
Discussion
See the NSText class specification for more information on this text delegate method. For additional details, see the NSControl class specification.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.htextDidEndEditing:
Updates 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).
Parameters
- aNotification
The notification posted by the field editor.
Discussion
See the NSText class specification for more information on this text delegate method.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.htextShouldBeginEditing:
Queries the delegate to determine if the text should begin editing.
Parameters
- textObject
The text object
Return Value
YES if editing of the text, otherwise NO. Returns YES if the delegate does not implement control:textShouldBeginEditing:.
Discussion
See the NSText class specification for more information on this text delegate method.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.htextShouldEndEditing:
Validates the text object for the cell being edited by querying the delegate.queries the delegate using control:textShouldEndEditing:, returning the delegate’s response if it responds to that method.
Parameters
- textObject
The
NSTextobject for the cell.
Return Value
Returns the value of the delegate’s implementation of control:textShouldEndEditing:. If the delegate does not implement the method, returns YES if the cell’s new value is valid, otherwise NO.
Discussion
See the NSText class specification for more information on this text delegate method.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.htile
Properly sizes the receiver and its header view and marks it as needing display.
Discussion
Also resets cursor rectangles for the header view and line scroll amounts for the NSScrollView object.
Generally for performance it is not recommend to call this method. Instead, the table will call it automatically when necessary.
Availability
- Available in OS X v10.0 and later.
See Also
-
setNeedsDisplay:(NSView)
Declared In
NSTableView.husesAlternatingRowBackgroundColors
Returns a Boolean value that indicates whether the receiver uses the standard alternating row colors for its background.
Return Value
YES if the receiver uses standard alternating row colors for the background, NO if it uses a solid color.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTableView.hverticalMotionCanBeginDrag
Returns whether vertical motion is treated as a drag or selection change.
Return Value
YES if a vertical drag motion can begin a drag, otherwise NO.
Discussion
The default is YES. In this case a vertical drag will drag-select rows.
Note that horizontal motion is always a valid motion to begin a drag.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hviewAtColumn:row:makeIfNecessary:
Returns a view at the specified row and column indexes, creating one if necessary.
Parameters
- column
The index of the column in the
tableColumnsarray.- row
The row index.
- makeIfNecessary
YESif a view is required,NOif you want to update properties on a view, if one is available.
Return Value
An instance of NSView.
Discussion
This method will first attempt to return an available view, which is generally in the visible area. If there is no available view, and makeIfNecessary is YES, a prepared temporary view is returned. If makeIfNecessary is NO, and the view is not available, nil will be returned.
In general, makeIfNecessary should be YES if you require a resulting view, and NO if you only want to update properties on a view only if it is available (generally this means it is visible).
An exception will be thrown if row is not within the numberOfRows. The returned result should generally not be held onto for longer than the current run loop cycle. Instead they should re-query the table view for the row view.
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTableView.hConstants
Specifying a Custom Row View In a NIB
The NSTableViewRowViewKey is the key that View-based TableView instances use to identify the NIB containing the template row view. You can specify a custom row view (without any code) by associating this key with the appropriate NIB name in Interface Builder.
NSString *const NSTableViewRowViewKey;
Constants
NSTableViewRowViewKeyThe key associated with the identifier in the nib containing the template row view.
Available in OS X v10.7 and later.
Declared in
NSTableView.h.
Special Considerations
This constant is only applicable to View-based table views.
NSTableViewDraggingDestinationFeedbackStyle
These constants specify the drag styles displayed by the table view. They’re used by the setDraggingDestinationFeedbackStyle: and draggingDestinationFeedbackStyle.
enum {
NSTableViewDraggingDestinationFeedbackStyleNone = -1,
NSTableViewDraggingDestinationFeedbackStyleRegular = 0,
NSTableViewDraggingDestinationFeedbackStyleSourceList = 1,
};
#endif
typedef NSInteger NSTableViewDraggingDestinationFeedbackStyle;
Constants
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 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 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 toNSTableViewDraggingDestinationFeedbackStyleSourceList. This is the standard look for Source Lists, but may be used in other areas as needed.Available in OS X v10.6 and later.
Declared in
NSTableView.h.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTableView.hNSTableViewDropOperation
NSTableView defines these constants to specify drop operations.
enum {
NSTableViewDropOn,
NSTableViewDropAbove
};
typedef NSUInteger NSTableViewDropOperation;
Constants
NSTableViewDropOnSpecifies that the drop should occur on the specified row.
Available in OS X v10.0 and later.
Declared in
NSTableView.h.NSTableViewDropAboveSpecifies that the drop should occur above the specified row.
Available in OS X v10.0 and later.
Declared in
NSTableView.h.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hGrid styles
NSTableView 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,
NSTableViewDashedHorizontalGridLineMask = 1 << 3,
};
typedef NSUInteger NSTableViewGridLineStyle;
Constants
NSTableViewGridNoneSpecifies that no grid lines should be displayed.
Available in OS X v10.3 and later.
Declared in
NSTableView.h.NSTableViewSolidVerticalGridLineMaskSpecifies that vertical grid lines should be displayed.
Available in OS X v10.3 and later.
Declared in
NSTableView.h.NSTableViewSolidHorizontalGridLineMaskSpecifies that horizontal grid lines should be displayed.
Available in OS X v10.3 and later.
Declared in
NSTableView.h.NSTableViewDashedHorizontalGridLineMaskSpecifies that the horizontal grid lines should be drawn dashed.
Available in OS X v10.7 and later.
Declared in
NSTableView.h.
NSTableViewColumnAutoresizingStyle
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;
Constants
NSTableViewNoColumnAutoresizingDisable table column autoresizing.
Available in OS X v10.4 and later.
Declared in
NSTableView.h.NSTableViewUniformColumnAutoresizingStyleAutoresize all columns by distributing space equally, simultaneously.
Available in 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 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 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 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 OS X v10.4 and later.
Declared in
NSTableView.h.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTableView.hNSTableViewSelectionHighlightStyle
The following constants specify the selection highlight styles. These constants are used by setSelectionHighlightStyle: and selectionHighlightStyle.
enum {
NSTableViewSelectionHighlightStyleNone = -1,
NSTableViewSelectionHighlightStyleRegular = 0,
NSTableViewSelectionHighlightStyleSourceList = 1,
};
typedef NSInteger NSTableViewSelectionHighlightStyle;
Constants
NSTableViewSelectionHighlightStyleNoneDisplays no highlight style at all.
Available in OS X v10.6 and later.
Declared in
NSTableView.h.NSTableViewSelectionHighlightStyleRegularThe regular highlight style of NSTableView. On OS X v10.7 a light blue (returned by sending
NSColoraalternateSelectedControlColormessage) or light gray color (returned by sending NSColor asecondarySelectedControlColormessage).Available in 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.
Note: When using this style, cell subclasses that implement
drawsBackgroundmust set the value toNO. Otherwise, the cells will draw over the tableview’s highlighting.Available in OS X v10.5 and later.
Declared in
NSTableView.h.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTableView.hNo Animation Effects
Specifies that no animation effect should be used by the table. This constant is used by the methods insertRowsAtIndexes:withAnimation: and removeRowsAtIndexes:withAnimation:.
enum {
NSTableViewAnimationEffectNone = 0x0,
};
Constants
NSTableViewAnimationEffectNoneSpecifies no animation effect should be used. Specifying any animation negates this effect.
Available in OS X v10.7 and later.
Declared in
NSTableView.h.
Row Animation Effects
Optional constant that specifies that the tableview will use a fade for row or column removal. The effect can be combined with any NSTableViewAnimationOptions constant.
enum {
NSTableViewAnimationEffectFade = 0x1,
NSTableViewAnimationEffectGap = 0x2,
};
Constants
NSTableViewAnimationEffectFadeSpecifies that the tableview will use a fade for row or column removal. The effect can be combined with any
NSTableViewAnimationOptionsconstant.Available in OS X v10.7 and later.
Declared in
NSTableView.h.NSTableViewAnimationEffectGapCreates a gap for newly inserted rows. This is useful for drag and drop animations that animate to a newly opened gap and should be used in the delegate method
tableView:acceptDrop:row:dropOperation:.Available in OS X v10.7 and later.
Declared in
NSTableView.h.
NSTableViewAnimationOptions
Optional animation slide effects used when inserting or removing rows. Currently only a single option may be selected. This effect can be combined with the “Row Animation Effects” constants. This constant is used by the methods Getting and Setting Row Size Styles and Column Management.
enum {
NSTableViewAnimationSlideUp = 0x10,
NSTableViewAnimationSlideDown = 0x20,
NSTableViewAnimationSlideLeft = 0x30,
NSTableViewAnimationSlideRight = 0x40,
};
typedef NSUInteger NSTableViewAnimationOptions;
Constants
NSTableViewAnimationSlideUpAnimates a row insertion or removal by sliding upward.
Available in OS X v10.7 and later.
Declared in
NSTableView.h.NSTableViewAnimationSlideDownAnimates a row insertion or removal by sliding downward.
Available in OS X v10.7 and later.
Declared in
NSTableView.h.NSTableViewAnimationSlideLeftAnimates a row insertion by sliding from the left. Animates a row removal by sliding towards the left.
Available in OS X v10.7 and later.
Declared in
NSTableView.h.NSTableViewAnimationSlideRightAnimates a row insertion by sliding from the right. Animates a row removal by sliding towards the right.
Available in OS X v10.7 and later.
Declared in
NSTableView.h.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hNSTableViewRowSizeStyle
The row size style constants define the size of the rows in the table view. They are used by the effectiveRowSizeStyle, setRowSizeStyle:, and rowSizeStyle methods. You can also query the row size in the NSTableCellView class’ property rowSizeStyle.
enum {
NSTableViewRowSizeStyleDefault = -1,
NSTableViewRowSizeStyleCustom = 0,
NSTableViewRowSizeStyleSmall = 1,
NSTableViewRowSizeStyleMedium = 2,
NSTableViewRowSizeStyleLarge = 3,
};
typedef NSInteger NSTableViewRowSizeStyle;
Constants
NSTableViewRowSizeStyleDefaultThe table will use the system default layout size: small, medium or large.
Available in OS X v10.7 and later.
Declared in
NSTableView.h.NSTableViewRowSizeStyleCustomThe table will use the
rowHeightor invoke the delegate methodtableView:heightOfRow:, if implemented. The cell layout is not changed.Available in OS X v10.7 and later.
Declared in
NSTableView.h.NSTableViewRowSizeStyleSmallThe table will use a row height specified for a small table. It is required that the size be fully tested and supported if
NSTableViewRowSizeStyleCustomis not used.Available in OS X v10.7 and later.
Declared in
NSTableView.h.NSTableViewRowSizeStyleMediumThe table will use a row height specified for a medium table. It is required that the size be fully tested and supported if
NSTableViewRowSizeStyleCustomis not used.Available in OS X v10.7 and later.
Declared in
NSTableView.h.NSTableViewRowSizeStyleLargeThe table will use a row height specified for a large table. It is required that the size be fully tested and supported if
NSTableViewRowSizeStyleCustomis not used.Available in OS X v10.7 and later.
Declared in
NSTableView.h.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTableView.hNotifications
NSTableViewColumnDidMoveNotification
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 |
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableView.hNSTableViewColumnDidResizeNotification
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. |
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hNSTableViewSelectionDidChangeNotification
NSTableView object's selection changes. The notification object is the table view whose selection changed. This notification does not contain a userInfo dictionary.Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.hNSTableViewSelectionIsChangingNotification
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.Availability
- Available in OS X v10.0 and later.
Declared In
NSTableView.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)