Mac Developer Library

Developer

AppKit Framework Reference NSTableView Class Reference

Options
Deployment Target:

On This Page
Language:

NSTableView

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 v10.7, you can use NSView objects (most commonly customized NSTableCellView objects) instead of cells for specifying rows and columns. You can still use NSCell objects for each row and column item if you prefer.

A table view does not store its own data; it retrieves data values as needed from a data source to which it has a weak reference. You should not, therefore, directly set data values programmatically in the table view; instead, modify the values in the data source and allow the changes to be reflected in the table view. To learn about the methods that an NSTableView object uses to provide and access the contents of its data source object, see NSTableViewDataSource Protocol Reference.

To customize a table view’s behavior without subclassing NSTableView, use the methods defined by the NSTableViewDelegate protocol. For example, the delegate supports table column management, type-to-select functionality, row selection and editing, custom tracking, and custom views for individual columns and rows. To learn more about the table view delegate, see NSTableViewDelegate Protocol Reference.

Subclassing

Subclassing NSTableView is usually not necessary. Instead, you customize the table view using a delegate object (an object conforming to the NSTableViewDelegate Protocol protocol) and a data source object (conforming to the NSTableViewDataSource protocol), or by subclassing one of the following subcomponents: cells (when using NSCell-based table views), the row cell view or the row view (when using NSView-based table views), the table column class, or table column header classes.

  • Returns a new or existing view with the specified identifier.

    Declaration

    Swift

    func makeViewWithIdentifier(_ identifier: String, owner owner: AnyObject?) -> NSView?

    Objective-C

    - (__kindofNSView *)makeViewWithIdentifier:(NSString *)identifier owner:(id)owner

    Parameters

    identifier

    The view identifier. Must not be nil.

    owner

    The owner of the NIB that may be loaded and instantiated to create a new view with the specified identifier.

    Return Value

    A view for the row.

    Discussion

    Typically, identifier is associated with a cell view that’s contained in a table’s nib file. When this method is called, the table view automatically instantiates the cell view with the specified owner, which is usually the table view’s delegate. (The owner is useful in setting up outlets and target/actions from the view.) Note that a cell view’s identifier must be the same as its table column’s identifier for bindings to work. If you’re using bindings, it’s recommended that you use the Automatic identifier setting in Interface Builder.

    This method may also return a reused view with the same identifier that is no longer available on screen. If a view with the specified identifier can’t be instantiated from the nib file or found in the reuse queue, this method returns nil.

    This method is usually called by the delegate in tableView:viewForTableColumn:row:, but it can also be overridden to provide custom views for the identifier. Note that awakeFromNib is called each time this method is called, which means that awakeFromNib is also called on owner, even though the owner is already awake.

    Availability

    Available in OS X v10.7 and later.

  • Returns a row view at the specified index, creating one if necessary.

    Declaration

    Swift

    func rowViewAtRow(_ row: Int, makeIfNecessary makeIfNecessary: Bool) -> NSTableRowView?

    Objective-C

    - (__kindofNSTableRowView *)rowViewAtRow:(NSInteger)row makeIfNecessary:(BOOL)makeIfNecessary

    Parameters

    row

    The row index.

    makeIfNecessary

    YEStrue if a view is required, NOfalse if you want to update properties on a view, if one is available.

    Return Value

    An instance, or subclass, of NSTableRowView. Returning nil is also valid if makeIfNecessary is NOfalse and the view did not exist.

    Discussion

    This method first attempts to return a currently displayed view in the visible area. If there is no visible view, and makeIfNecessary is YEStrue, a prepared temporary view is returned. If makeIfNecessary is NOfalse, and the view is not visible, nil is returned.

    In general, makeIfNecessary should be YEStrue if you require a resulting view, and NOfalse if you want to update properties on a view only if it is available (generally this means it is visible).

    An exception is thrown if row falls outside of the number of rows in the table (numberOfRows). The returned result should generally not be held onto for longer than the current run loop cycle. It’s better to call rowViewAtRow:makeIfNecessary: whenever a view is required.

    Availability

    Available in OS X v10.7 and later.

  • Returns a view at the specified row and column indexes, creating one if necessary.

    Declaration

    Swift

    func viewAtColumn(_ column: Int, row row: Int, makeIfNecessary makeIfNecessary: Bool) -> NSView?

    Objective-C

    - (__kindofNSView *)viewAtColumn:(NSInteger)column row:(NSInteger)row makeIfNecessary:(BOOL)makeIfNecessary

    Parameters

    column

    The index of the column in the tableColumns array.

    row

    The row index.

    makeIfNecessary

    YEStrue if a view is required, NOfalse if you want to update properties on a view, if one is available.

    Return Value

    An instance of NSView.

    Discussion

    This method first attempts to return an available view, which is generally in the visible area. If there is no available view, and makeIfNecessary is YEStrue, a prepared temporary view is returned. If makeIfNecessary is NOfalse, and the view is not available, nil will be returned.

    In general, makeIfNecessary should be YEStrue if you require a resulting view, and NOfalse 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.

  • Registers a NIB for the identifier, so that view-based table views can use it to instantiate views.

    Declaration

    Swift

    func registerNib(_ nib: NSNib?, forIdentifier identifier: String)

    Objective-C

    - (void)registerNib:(NSNib *)nib forIdentifier:(NSString *)identifier

    Parameters

    nib

    The NIB containing the view.

    identifier

    The identifier of the view to create.

    Discussion

    This method registers (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 called, and there was no NIB created at design time for the specified identifier. This allows dynamic loading of NIBs that can be associated with the table.

    To remove a previously associated NIB for identifier, pass in nil for the nib value.

    Availability

    Available in OS X v10.8 and later.

  • The dictionary of all registered nib files for view-based table view identifiers. (read-only)

    Declaration

    Swift

    var registeredNibsByIdentifier: [String : NSNib]? { get }

    Objective-C

    @property(readonly, copy) NSDictionary <NSString *,NSNib *> *registeredNibsByIdentifier

    Discussion

    Each key in the dictionary is the identifier string used to register the nib file in the registerNib:forIdentifier: method. The value of each key is the corresponding NSNib object.

    Availability

    Available in OS X v10.8 and later.

  • The message sent to the table view’s target when the user double-clicks a cell or column header.

    Declaration

    Swift

    var doubleAction: Selector

    Objective-C

    @property SEL doubleAction

    Discussion

    This property stores a selector that corresponds to a method of the following form:

    1. -(void)myCustomMethod:(id)sender

    When the user double-clicks a cell or column header, the table calls the specified method of its target object. The default value of this property is nil. If you do not specify a value for this property, the table view begins editing the cell.

    The clickedRow and clickedColumn properties allow you to determine which row and column the double-click occurred in or if, rather than in a row, the double-click occurred 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

    target (NSControl)

  • The index of the column the user clicked. (read-only)

    Declaration

    Swift

    var clickedColumn: Int { get }

    Objective-C

    @property(readonly) NSInteger clickedColumn

    Discussion

    This property contains the index in the tableColumns array of the column that the user clicked. The value is -1 when the user clicks in an area of the table view that is not occupied by columns or when the user clicks a row that is a group separator.

    The value of this property is meaningful in the target object’s implementation of the action and double-action methods. You can also use the value to determine which contextual menu to display when the user Control-clicks in a table. Note that the clickedColumn value remains valid when the menu item sends the action message. To see an example of using clickedColumn in the implementation of a contextual menu, download the DragNDropOutlineView: implementing drag and drop in an NSOutlineView sample project.

    Availability

    Available in OS X v10.0 and later.

    See Also

    clickedRow
    setAction: (NSControl)
    doubleAction

  • The index of the row the user clicked.

    Declaration

    Swift

    var clickedRow: Int { get }

    Objective-C

    @property(readonly) NSInteger clickedRow

    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

    This property contains the index of the row that the user clicked. The value is -1 when the user clicks in an area of the table view that is not occupied by table rows.

    The value of this property is meaningful in the target object’s implementation of the action and double-action methods. You can also use the value to determine which contextual menu to display when the user Control-clicks in a table. Note that you should check to see if clickedRow is one of the rows the user selected and if it is, perform the contextual menu operation on all of the selected rows. To see an example of using clickedRow in the implementation of a contextual menu, download the DragNDropOutlineView: implementing drag and drop in an NSOutlineView sample project.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value indicating whether the table view allows the user to rearrange columns by dragging their headers.

    Declaration

    Swift

    var allowsColumnReordering: Bool

    Objective-C

    @property BOOL allowsColumnReordering

    Discussion

    The default value of this property is YEStrue, which allows the user to rearrange the table view’s columns. You can rearrange columns programmatically regardless of this setting.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value indicating whether the table view allows the user to resize columns by dragging between their headers.

    Declaration

    Swift

    var allowsColumnResizing: Bool

    Objective-C

    @property BOOL allowsColumnResizing

    Discussion

    The default of this property is YEStrue, which allows the user to resize the table view’s columns. You can resize columns programmatically regardless of this setting.

    Availability

    Available in OS X v10.0 and later.

    See Also

    setWidth: (NSTableColumn)

  • A Boolean value indicating whether the table view allows the user to select more than one column or row at a time.

    Declaration

    Swift

    var allowsMultipleSelection: Bool

    Objective-C

    @property BOOL allowsMultipleSelection

    Discussion

    The default is NOfalse, which allows the user to select only one column or row at a time. You can select multiple columns or rows programmatically regardless of this setting.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value indicating whether the table view allows the user to select zero columns or rows.

    Declaration

    Swift

    var allowsEmptySelection: Bool

    Objective-C

    @property BOOL allowsEmptySelection

    Discussion

    The default is YEStrue, which allows the user to select zero columns or rows.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value indicating whether the table view allows the user to select columns by clicking their headers.

    Declaration

    Swift

    var allowsColumnSelection: Bool

    Objective-C

    @property BOOL allowsColumnSelection

    Discussion

    The default is NOfalse, which prevents the user from selecting columns. You can select columns programmatically regardless of this setting.

    Availability

    Available in OS X v10.0 and later.

  • The horizontal and vertical spacing between cells.

    Declaration

    Swift

    var intercellSpacing: NSSize

    Objective-C

    @property NSSize intercellSpacing

    Return Value

    The horizontal and vertical spacing between cells.

    Discussion

    The default spacing is (3.0, 2.0). Changing the value of this property causes the table view to redisplay itself.

    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.

  • The height of each row in the table.

    Declaration

    Swift

    var rowHeight: CGFloat

    Objective-C

    @property CGFloat rowHeight

    Discussion

    The default row height is 16.0. The value in this property is used only if the table's rowSizeStyle is set to NSTableViewRowSizeStyleCustom.

    When you change the value of this property, the table view calls the tile method to redisplay the rows using the new value.

    Availability

    Available in OS X v10.0 and later.

    See Also

    rowSizeStyle

  • The color used to draw the background of the table.

    Declaration

    Swift

    @NSCopying var backgroundColor: NSColor

    Objective-C

    @property(copy) NSColor *backgroundColor

    Discussion

    The default background color is light gray.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value indicating whether the table view uses alternating row colors for its background.

    Declaration

    Swift

    var usesAlternatingRowBackgroundColors: Bool

    Objective-C

    @property BOOL usesAlternatingRowBackgroundColors

    Return Value

    YEStrue if the table view uses standard alternating row colors for the background, NOfalse if it uses a solid color.

    Discussion

    When the value of this property is YEStrue, the table uses the standard alternating row colors for the background. When the value is NOfalse, the table view uses a single solid color for the background.

    Availability

    Available in OS X v10.3 and later.

  • The selection highlight style used by the table view to indicate row and column selection.

    Declaration

    Swift

    var selectionHighlightStyle: NSTableViewSelectionHighlightStyle

    Objective-C

    @property NSTableViewSelectionHighlightStyle selectionHighlightStyle

    Discussion

    Setting the selection highlight style to NSTableViewSelectionHighlightStyleSourceList causes the table view 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.

  • The color used to draw grid lines.

    Declaration

    Swift

    @NSCopying var gridColor: NSColor

    Objective-C

    @property(copy) NSColor *gridColor

    Discussion

    The default color is gray.

    Availability

    Available in OS X v10.0 and later.

  • The grid lines drawn by the table view.

    Declaration

    Swift

    var gridStyleMask: NSTableViewGridLineStyle

    Objective-C

    @property NSTableViewGridLineStyle gridStyleMask

    Discussion

    Use this property to specify whether lines should be drawn between rows and columns. When setting this property, you can specify multiple styles at once by adding the corresponding constants together. The default value of this property is NSTableViewGridNone.

    Availability

    Available in OS X v10.3 and later.

  • Returns the indicator image of the specified table column.

    Declaration

    Swift

    func indicatorImageInTableColumn(_ tableColumn: NSTableColumn) -> NSImage?

    Objective-C

    - (NSImage *)indicatorImageInTableColumn:(NSTableColumn *)aTableColumn

    Parameters

    aTableColumn

    A table column in the table view.

    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.

  • Sets the indicator image of the specified column.

    Declaration

    Swift

    func setIndicatorImage(_ anImage: NSImage?, inTableColumn tableColumn: NSTableColumn)

    Objective-C

    - (void)setIndicatorImage:(NSImage *)anImage inTableColumn:(NSTableColumn *)aTableColumn

    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.

  • Allows the enumeration of all the table rows that are known to the table view.

    Declaration

    Swift

    func enumerateAvailableRowViewsUsingBlock(_ handler: (NSTableRowView, Int) -> Void)

    Objective-C

    - (void)enumerateAvailableRowViewsUsingBlock:(void (^)(__kindof NSTableRowView *rowView, NSInteger row))handler

    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.

  • A Boolean value indicating whether the table view allows the user to type characters to select rows.

    Declaration

    Swift

    var allowsTypeSelect: Bool

    Objective-C

    @property BOOL allowsTypeSelect

    Discussion

    The default value of this property is YEStrue. Set it to NOfalse if you want to disable selecting rows by typing.

    Availability

    Available in OS X v10.5 and later.

  • The number of columns in the table. (read-only)

    Declaration

    Swift

    var numberOfColumns: Int { get }

    Objective-C

    @property(readonly) NSInteger numberOfColumns

    Discussion

    The value in this property includes table columns that are currently hidden.

    Availability

    Available in OS X v10.0 and later.

    See Also

    numberOfRows

  • The number of rows in the table. (read-only)

    Declaration

    Swift

    var numberOfRows: Int { get }

    Objective-C

    @property(readonly) NSInteger numberOfRows

    Discussion

    Typically you should not ask the table view how many rows it has; instead, interrogate the table view's data source.

    Availability

    Available in OS X v10.0 and later.

    See Also

    numberOfColumns
    numberOfRowsInTableView: (NSTableViewDataSource protocol)

  • A Boolean value indicating whether the table view draws grouped rows as if they are floating.

    Declaration

    Swift

    var floatsGroupRows: Bool

    Objective-C

    @property BOOL floatsGroupRows

    Discussion

    Group rows are rows for which the table view delegate’s tableView:isGroupRow: method returns YES. These rows can be displayed as if they are floating in a view-based table view.

    The default value of this property is YEStrue.

    Availability

    Available in OS X v10.7 and later.

  • Edits the cell at the specified column and row using the specified event and selection behavior.

    Declaration

    Swift

    func editColumn(_ column: Int, row row: Int, withEvent theEvent: NSEvent?, select select: Bool)

    Objective-C

    - (void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag

    Parameters

    columnIndex

    The index of the column in the tableColumns array.

    rowIndex

    The row index.

    theEvent

    The event.

    flag

    YEStrue if the entered contents should be selected, otherwise NOfalse.

    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 table view so that the cell is visible and sets up the field editor. If flag is NOfalse, it calls the editWithFrame:inView:editor:delegate:event: method of the field editor’s NSCell object, providing the NSTableView as the text delegate. If flag is YEStrue, this method calls the selectWithFrame:inView:editor:delegate:start:length: method instead.

    This method can be overridden to customize drawing for rowIndex when using NSCell-based table views.

    Availability

    Available in OS X v10.0 and later.

  • The index of the column being edited. (read-only)

    Declaration

    Swift

    var editedColumn: Int { get }

    Objective-C

    @property(readonly) NSInteger editedColumn

    Return Value

    If sent during editColumn:row:withEvent:select:, the index in the tableColumns array of the column being edited; otherwise –1.

    Discussion

    This property does not apply to view-based table views. In a view-based table view, the views are responsible for their own editing behavior. For other tables, the value reflects the index of the column being edited or –1 when there is no editing session in progress or when the currently edited row is a "full width" row.

    Availability

    Available in OS X v10.0 and later.

  • The index of the row being edited. (read-only)

    Declaration

    Swift

    var editedRow: Int { get }

    Objective-C

    @property(readonly) NSInteger editedRow

    Discussion

    This property does not apply to view-based table views. In a view-based table view, the views are responsible for their own editing behavior. For other tables, the value reflects the index of the row being edited or –1 when there is no editing session in progress.

    Availability

    Available in OS X v10.0 and later.

  • Invoked when a row view is added to the table.

    Declaration

    Swift

    func didAddRowView(_ rowView: NSTableRowView, forRow row: Int)

    Objective-C

    - (void)didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row

    Parameters

    rowView

    The row view.

    row

    The row index.

    Discussion

    The subclass can implement this method to be alerted when rowView has been added to the table. At this point, the subclass can choose to add in extra views, or modify any properties of rowView. Subclasses must be sure to call super.

    Availability

    Available in OS X v10.7 and later.

  • Invoked when a row view was removed from the table.

    Declaration

    Swift

    func didRemoveRowView(_ rowView: NSTableRowView, forRow row: Int)

    Objective-C

    - (void)didRemoveRowView:(NSTableRowView *)rowView forRow:(NSInteger)row

    Parameters

    rowView

    The row view.

    row

    The row index. The index is -1 for rows that are being deleted from the table, and no longer have a valid row; otherwise it is the valid row that is being removed due to it being moved off screen.

    Discussion

    The subclass can implement this method to be alerted when rowView has been removed from the table. The removed rowView may be reused by the table, so any additionally inserted views should be removed at this point. Subclasses must be sure to call super.

    Availability

    Available in OS X v10.7 and later.

  • The view object used to draw headers over columns.

    Declaration

    Swift

    var headerView: NSTableHeaderView?

    Objective-C

    @property(strong) NSTableHeaderView *headerView

    Discussion

    To configure a table without a header view or to remove the table view’s current header view, set the value of this property to nil. For more information about header views, see NSTableHeaderView Class Reference.

    Availability

    Available in OS X v10.0 and later.

  • The view used to draw the area to the right of the column headers and above the vertical scroller of the enclosing scroll view.

    Declaration

    Swift

    var cornerView: NSView?

    Objective-C

    @property(strong) NSView *cornerView

    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

    The default corner view 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 header view of the table view.

    Availability

    Available in OS X v10.0 and later.

    See Also

    headerView

  • Returns the rectangle containing the column at the specified index.

    Declaration

    Swift

    func rectOfColumn(_ column: Int) -> NSRect

    Objective-C

    - (NSRect)rectOfColumn:(NSInteger)columnIndex

    Parameters

    columnIndex

    The index in the tableColumns array of a column in the table view.

    Return Value

    The rectangle containing the column at columnIndex. Returns NSZeroRect if columnIndex lies outside the range of valid column indexes for the table view.

    Discussion

    You can use this method to update a single column more efficiently than sending the table view a reloadData message.

    1. [aTableView setNeedsDisplayInRect:[aTableView rectOfColumn:column]];

    Availability

    Available in OS X v10.0 and later.

  • Returns the rectangle containing the row at the specified index.

    Declaration

    Swift

    func rectOfRow(_ row: Int) -> NSRect

    Objective-C

    - (NSRect)rectOfRow:(NSInteger)row

    Return Value

    The rectangle containing the row at rowIndex. Returns NSZeroRect if rowIndex lies outside the range of valid row indexes for the table view.

    Discussion

    You can use this method to update a single row more efficiently than sending the table view a reloadData message.

    1. [aTableView setNeedsDisplayInRect:[aTableView rectOfRow:row]];

    Availability

    Available in OS X v10.0 and later.

  • Returns a range of indexes for the rows that lie wholly or partially within the vertical boundaries of the specified rectangle.

    Declaration

    Swift

    func rowsInRect(_ rect: NSRect) -> NSRange

    Objective-C

    - (NSRange)rowsInRect:(NSRect)aRect

    Parameters

    aRect

    A rectangle in the coordinate system of the table view.

    Return Value

    A range of indexes for the table view’s rows that lie wholly or partially within the horizontal boundaries of aRect. If the width or height of aRect is 0, this method returns an NSRange whose length is 0.

    Discussion

    The location of the range is the index of the first row in the rectangle, and the length is the number of rows that lie in the rectangle.

    Availability

    Available in OS X v10.0 and later.

  • Returns the indexes of the table view’s columns that intersect the specified rectangle.

    Declaration

    Swift

    func columnIndexesInRect(_ rect: NSRect) -> NSIndexSet

    Objective-C

    - (NSIndexSet *)columnIndexesInRect:(NSRect)rect

    Parameters

    rect

    The rectangle in the table view’s coordinate system to test for column enclosure.

    Return Value

    New NSIndexSet object containing the indexes of the table view’s columns that intersect with rect.

    Discussion

    Columns that return YEStrue for the NSTableColumn method isHidden are excluded from the results.

    Availability

    Available in OS X v10.5 and later.

  • Returns the index of the column the specified point lies in.

    Declaration

    Swift

    func columnAtPoint(_ point: NSPoint) -> Int

    Objective-C

    - (NSInteger)columnAtPoint:(NSPoint)aPoint

    Parameters

    aPoint

    A point in the coordinate system of the table view.

    Return Value

    The index in the tableColumns array of the column aPoint lies in, or –1 if aPoint lies outside the table view’s bounds.

    Availability

    Available in OS X v10.0 and later.

    See Also

    – rowAtPoint:

  • Returns the index of the row the specified point lies in.

    Declaration

    Swift

    func rowAtPoint(_ point: NSPoint) -> Int

    Objective-C

    - (NSInteger)rowAtPoint:(NSPoint)aPoint

    Parameters

    aPoint

    A point in the coordinate system of the table view.

    Return Value

    The index of the row aPoint lies in, or –1 if aPoint lies outside the table view’s bounds.

    Availability

    Available in OS X v10.0 and later.

  • Returns a rectangle locating the cell that lies at the intersection of the specified column and row.

    Declaration

    Swift

    func frameOfCellAtColumn(_ column: Int, row row: Int) -> NSRect

    Objective-C

    - (NSRect)frameOfCellAtColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex

    Parameters

    columnIndex

    The index in the tableColumns array 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. This method returns NSZeroRect if columnIndex or rowIndex is greater than the number of columns or rows in the table view.

    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.

  • The table view’s column autoresizing style.

    Declaration

    Swift

    var columnAutoresizingStyle: NSTableViewColumnAutoresizingStyle

    Objective-C

    @property NSTableViewColumnAutoresizingStyle columnAutoresizingStyle

    Discussion

    This property determines how columns are resized when the table view size changes. The default value of this property is NSTableViewLastColumnOnlyAutoresizingStyle.

    Availability

    Available in OS X v10.4 and later.

  • Resizes the last column so the table view fits exactly within its enclosing clip view.

    Declaration

    Swift

    func sizeLastColumnToFit()

    Objective-C

    - (void)sizeLastColumnToFit

    Availability

    Available in OS X v10.0 and later.

    See Also

    columnAutoresizingStyle
    minWidth (NSTableColumn)
    maxWidth (NSTableColumn)

  • Informs the table view that the number of records in its data source has changed.

    Declaration

    Swift

    func noteNumberOfRowsChanged()

    Objective-C

    - (void)noteNumberOfRowsChanged

    Discussion

    This method allows the table view to update the scrollers in its scroll view without actually reloading data into the table view. 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: (NSTableViewDataSource protocol)

  • Properly sizes the table view and its header view and marks it as needing display.

    Declaration

    Swift

    func tile()

    Objective-C

    - (void)tile

    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)

  • Sizes the table view based on a uniform column autoresizing style.

    Declaration

    Swift

    func sizeToFit()

    Objective-C

    - (void)sizeToFit

    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.

  • Informs the table view that the rows specified in indexSet have changed height.

    Declaration

    Swift

    func noteHeightOfRowsWithIndexesChanged(_ indexSet: NSIndexSet)

    Objective-C

    - (void)noteHeightOfRowsWithIndexesChanged:(NSIndexSet *)indexSet

    Parameters

    indexSet

    Index set of rows that have changed their height.

    Discussion

    If the delegate implements tableView:heightOfRow: this method immediately retiles the table view using the row heights the delegate provides.

    For NSView-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 NSCell-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.

  • The name under which table information is automatically saved.

    Declaration

    Swift

    var autosaveName: String?

    Objective-C

    @property(copy) NSString *autosaveName

    Discussion

    The table information is saved separately in user defaults for each user and for each application that user uses. If no name has been set, the value of this property is nil. Even when a table view has an autosave name, it only saves the table information when the autosaveTableColumns property is YEStrue.

    If you change the value of this property to a new name, the table reads in any saved information and sets the order and width of this table view’s columns to match. Setting the name to nil removes any previously stored state from the user defaults.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value indicating whether the order and width of the table view’s columns are automatically saved.

    Declaration

    Swift

    var autosaveTableColumns: Bool

    Objective-C

    @property BOOL autosaveTableColumns

    Discussion

    When this property is set to YEStrue, the table information is saved separately for each user and application under the name specified in the autosaveName property. If you change the value of this property from NOfalse to YEStrue, the table tries to read in any saved information and sets the order and width of this table view’s columns to match. If the autosaveName property is nil, this setting is ignored and the table information is not read or saved.

    When autosave is enabled, the table saves 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

    autosaveName

  • The column highlighted in the table.

    Declaration

    Swift

    unowned(unsafe) var highlightedTableColumn: NSTableColumn?

    Objective-C

    @property(assign) NSTableColumn *highlightedTableColumn

    Discussion

    Assigning a value to this property highlights the specified column. 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.

  • The table view’s sort descriptors.

    Declaration

    Swift

    var sortDescriptors: [NSSortDescriptor]

    Objective-C

    @property(copy) NSArray <NSSortDescriptor *> *sortDescriptors

    Discussion

    This property contains an array of NSSortDescriptor objects. 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. Changing the value of this property may have the side effect of calling the tableView:sortDescriptorsDidChange: method on the table view’s data source.

    The contents of this property are archived and persisted along with other column information if autosave is enabled for the table.

    Availability

    Available in OS X v10.3 and later.

  • A Boolean value indicating whether a table row’s actions are visible.

    Declaration

    Swift

    var rowActionsVisible: Bool

    Objective-C

    @property BOOL rowActionsVisible

    Discussion

    This property contains a Boolean value indicating whether a table row’s actions are visible or not—the user has swiped the row to reveal the row actions. Set the value of this property to NOfalse to hide any visible row actions. Setting the value of this property to YEStrue is not supported, and will result in an exception.

    Availability

    Available in OS X v10.11 and later.

  • Computes and returns an image to use for dragging.

    Deprecation Statement

    Use dragImageForRowsWithIndexes:tableColumns:event:offset: instead.

    Declaration

    Objective-C

    - (NSImage *)dragImageForRows:(NSArray *)dragRows event:(NSEvent *)dragEvent dragImageOffset:(NSPointPointer)dragImageOffset

    Discussion

    Override this to return a custom image. dragRows represents the rows participating in the drag. 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.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.4.

  • Controls whether the table view proportionally resizes its columns to fit when its superview’s frame changes.

    Deprecation Statement

    Use columnAutoresizingStyle instead.

    Declaration

    Objective-C

    - (void)setAutoresizesAllColumnsToFit:(BOOL)flag

    Discussion

    If flag is YEStrue, the difference in width is distributed among the table view’s table columns; if flag is NOfalse, only the last column is resized to fit.

    To preserve compatibility this method sets the autoresizing style to NSTableViewUniformColumnAutoresizingStyle , if flag is YEStrue. Otherwise the autoresizing style is set to NSTableViewLastColumnOnlyAutoresizingStyle.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.4.

  • Returns YEStrue if the table view proportionally resizes its columns to fit when its superview’s frame changes, NOfalse if it only resizes the last column.

    Deprecation Statement

    Use columnAutoresizingStyle instead.

    Declaration

    Objective-C

    - (BOOL)autoresizesAllColumnsToFit

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.4.

  • Selects the column at the specified index, optionally extending any existing selection.

    Deprecation Statement

    Use selectColumnIndexes:byExtendingSelection: instead.

    Declaration

    Objective-C

    - (void)selectColumn:(NSInteger)column byExtendingSelection:(BOOL)extend

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.3.

  • Selects a row at the specified index, optionally extending any existing selection.

    Deprecation Statement

    Use selectRowIndexes:byExtendingSelection: instead.

    Declaration

    Objective-C

    - (void)selectRow:(NSInteger)row byExtendingSelection:(BOOL)extend

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.3.

  • Writes the specified rows to the specified pasteboard.

    Deprecation Statement

    This method has been deprecated. You should implement tableView:writeRowsWithIndexes:toPasteboard: instead.

    Declaration

    Objective-C

    - (BOOL)tableView:(NSTableView *)aTableView writeRows:(NSArray *)rows toPasteboard:(NSPasteboard *)pboard

    Discussion

    Invoked by aTableView after it has been determined that a drag should begin, but before the drag has been started. To refuse the drag, return NOfalse. To start a drag, return YEStrue and place the drag data onto pboard (data, owner, and so on). The drag image and other drag-related information will be set up and provided by the table view once this call returns with YEStrue. rows is the list of row numbers that will be participating in the drag.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.4.

  • - setDrawsGrid: (OS X v10.3)

    Sets whether the table view draws a grid.

    Deprecation Statement

    Use gridStyleMask instead.

    Declaration

    Objective-C

    - (void)setDrawsGrid:(BOOL)flag

    Parameters

    flag

    Whether or not to draw the grid.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.3.

  • - drawsGrid (OS X v10.3)

    Returns a Boolean value that indicates whether the table view draws a grid.

    Deprecation Statement

    Use gridStyleMask instead.

    Declaration

    Objective-C

    - (BOOL)drawsGrid

    Return Value

    Returns whether the grid is drawn.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.3.

  • This method has been deprecated.

    Deprecation Statement

    Use selectedColumnIndexes instead.

    Declaration

    Objective-C

    - (NSEnumerator *)selectedColumnEnumerator

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.3.

  • This method has been deprecated.

    Deprecation Statement

    Use selectedRowIndexes instead.

    Declaration

    Objective-C

    - (NSEnumerator *)selectedRowEnumerator

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.3.

  • Returns the currently focused column.

    Deprecation Statement

    Use a view-based table view and observe the window’s first responder.

    Declaration

    Swift

    func focusedColumn() -> Int

    Objective-C

    - (NSInteger)focusedColumn

    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.5 and later.

    Deprecated in OS X v10.10.

  • Sets the currently focused column to the specified index.

    Deprecation Statement

    Use a view-based table view and make a particular view the first responder to focus it.

    Declaration

    Swift

    func setFocusedColumn(_ focusedColumn: Int)

    Objective-C

    - (void)setFocusedColumn:(NSInteger)focusedColumn

    Parameters

    focusedColumn

    The index of the column to focus, or -1 if there should be no focused column.

    Discussion

    This method will redisplay the previously focused column and (if required) the new focusedColumn.

    The focused column has a focus ring drawn around the selectedRow that intersects with focusedColumn.

    You should not override this method.

    Availability

    Available in OS X v10.6 and later.

    Deprecated in OS X v10.10.

  • Returns whether the fully prepared cell at the specified row and column can be made the focused cell.

    Deprecation Statement

    Use a view-based table view and observe the window’s first responder.

    Declaration

    Swift

    func shouldFocusCell(_ cell: NSCell, atColumn column: Int, row row: Int) -> Bool

    Objective-C

    - (BOOL)shouldFocusCell:(NSCell *)cell atColumn:(NSInteger)column row:(NSInteger)row

    Parameters

    cell

    The prepared cell to be focused upon.

    column

    The column of the cell.

    row

    The row of the cell.

    Return Value

    YEStrue if the cell can be made the focused cell, otherwise NOfalse.

    Discussion

    By default, only cells that are enabled can be focused. In addition, if the cell is an NSTextFieldCell, it can only be focused if it is selectable or editable, and the table view delegate responds YEStrue to -tableView:shouldEditTableColumn:row:.

    Subclasses can override this to further control which cells can and can’t be made focused.

    Availability

    Available in OS X v10.6 and later.

    Deprecated in OS X v10.10.

  • Performs a click action on the cell at the specified row and column.

    Deprecation Statement

    Use a view-based table view and use the view to handle user interactions.

    Declaration

    Swift

    func performClickOnCellAtColumn(_ column: Int, row row: Int)

    Objective-C

    - (void)performClickOnCellAtColumn:(NSInteger)column row:(NSInteger)row

    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 data source, 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.

    Deprecated in OS X v10.10.

  • Returns the fully prepared cell that the table view will use for drawing or processing of the specified row and column.

    Deprecation Statement

    Use a view-based table view and the viewAtColumn:row:makeIfNecessary: method.

    Declaration

    Swift

    func preparedCellAtColumn(_ column: Int, row row: Int) -> NSCell?

    Objective-C

    - (NSCell *)preparedCellAtColumn:(NSInteger)column row:(NSInteger)row

    Parameters

    column

    The index in the tableColumns array for which to return the appropriate cell.

    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.

    Deprecated in OS X v10.10.

  • - columnsInRect: (OS X v10.5)

    Returns a range of indexes for the table view’s columns that lie wholly or partially within the horizontal boundaries of the specified rectangle.

    Deprecation Statement

    Use columnIndexesInRect: instead.

    Declaration

    Objective-C

    - (NSRange)columnsInRect:(NSRect)aRect

    Parameters

    aRect

    A rectangle in the coordinate system of the table view.

    Return Value

    A range of indexes for the table view’s columns 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 column’s index, and the length is the number of columns that lie in aRect.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

    See Also

    – rowsInRect:

  • Queries the delegate to determine if the text should begin editing.

    Deprecation Statement

    Use a view-based table view with an NSTextField object instead.

    Declaration

    Swift

    func textShouldBeginEditing(_ textObject: NSText) -> Bool

    Objective-C

    - (BOOL)textShouldBeginEditing:(NSText *)textObject

    Parameters

    textObject

    The text object

    Return Value

    YEStrue if editing of the text should begin, otherwise NOfalse. Returns YEStrue 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.

    Deprecated in OS X v10.10.

  • Posts an NSControlTextDidBeginEditingNotification to the default notification center.

    Deprecation Statement

    Use a view-based table view with an NSTextField object instead.

    Declaration

    Swift

    func textDidBeginEditing(_ notification: NSNotification)

    Objective-C

    - (void)textDidBeginEditing:(NSNotification *)aNotification

    Parameters

    aNotification

    The notification posted by the field editor; see the NSText class 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.

    Deprecated in OS X v10.10.

  • Sends textDidChange: to the edited cell and posts an NSControlTextDidChangeNotification to the default notification center.

    Deprecation Statement

    Use a view-based table view with an NSTextField object instead.

    Declaration

    Swift

    func textDidChange(_ notification: NSNotification)

    Objective-C

    - (void)textDidChange:(NSNotification *)aNotification

    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.

    Deprecated in OS X v10.10.

  • 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.

    Deprecation Statement

    Use a view-based table view with an NSTextField object instead.

    Declaration

    Swift

    func textShouldEndEditing(_ textObject: NSText) -> Bool

    Objective-C

    - (BOOL)textShouldEndEditing:(NSText *)textObject

    Parameters

    textObject

    The NSText object 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 YEStrue if the cell’s new value is valid, otherwise NOfalse.

    Discussion

    See the NSText class specification for more information on this text delegate method.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.10.

  • 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).

    Deprecation Statement

    Use a view-based table view with an NSTextField object instead.

    Declaration

    Swift

    func textDidEndEditing(_ notification: NSNotification)

    Objective-C

    - (void)textDidEndEditing:(NSNotification *)aNotification

    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.

    Deprecated in OS X v10.10.

  • The NSTableViewRowViewKey is the key that view-based table view 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.

    Declaration

    Swift

    let NSTableViewRowViewKey: String

    Objective-C

    NSString *const NSTableViewRowViewKey;

    Constants

    • NSTableViewRowViewKey

      NSTableViewRowViewKey

      The key associated with the identifier in the NIB containing the template row view.

      Available in OS X v10.7 and later.

  • These constants specify the drag styles displayed by the table view. They’re used by draggingDestinationFeedbackStyle.

    Declaration

    Swift

    enum NSTableViewDraggingDestinationFeedbackStyle : Int { case None case Regular case SourceList case Gap }

    Objective-C

    typedef enum NSTableViewDraggingDestinationFeedbackStyle : NSInteger { NSTableViewDraggingDestinationFeedbackStyleNone = -1, NSTableViewDraggingDestinationFeedbackStyleRegular = 0, NSTableViewDraggingDestinationFeedbackStyleSourceList = 1, NSTableViewDraggingDestinationFeedbackStyleGap = 2 } NSTableViewDraggingDestinationFeedbackStyle;

    Constants

    • none

      NSTableViewDraggingDestinationFeedbackStyleNone

      Provides 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.

    • regular

      NSTableViewDraggingDestinationFeedbackStyleRegular

      Draws 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.

    • sourceList

      NSTableViewDraggingDestinationFeedbackStyleSourceList

      Draws 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 unhideRowsAtIndexes:withAnimation: is set to NSTableViewDraggingDestinationFeedbackStyleSourceList. 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.

    • gap

      NSTableViewDraggingDestinationFeedbackStyleGap

      Provides a gap insertion when dragging over the table. Note that this style is only officially supported for NSView-based table views, but may partially work in Cell Based TableViews. The decision to use the gap style (compared to another style) can be made in tableView:draggingSession:willBeginAtPoint:forRowIndexes:, or it can dynamically be changed.

      Available in OS X v10.9 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • NSTableView defines these constants to specify drop operations.

    Declaration

    Swift

    enum NSTableViewDropOperation : UInt { case On case Above }

    Objective-C

    typedef enum NSTableViewDropOperation : NSUInteger { NSTableViewDropOn, NSTableViewDropAbove } NSTableViewDropOperation;

    Constants

    • on

      NSTableViewDropOn

      Specifies that the drop should occur on the specified row.

      Available in OS X v10.0 and later.

    • above

      NSTableViewDropAbove

      Specifies that the drop should occur above the specified row.

      Available in OS X v10.0 and later.

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • NSTableView defines these constants to specify grid styles. These constants are used by the gridStyleMask property. The mask can be either NSTableViewGridNone or it can contain either or both of the other options combined using the C bitwise OR operator.

    Declaration

    Swift

    struct NSTableViewGridLineStyle : OptionSetType { init(rawValue rawValue: UInt) static var GridNone: NSTableViewGridLineStyle { get } static var SolidVerticalGridLineMask: NSTableViewGridLineStyle { get } static var SolidHorizontalGridLineMask: NSTableViewGridLineStyle { get } static var DashedHorizontalGridLineMask: NSTableViewGridLineStyle { get } }

    Objective-C

    typedef enum NSTableViewGridLineStyle : NSUInteger { NSTableViewGridNone = 0, NSTableViewSolidVerticalGridLineMask = 1 << 0, NSTableViewSolidHorizontalGridLineMask = 1 << 1, NSTableViewDashedHorizontalGridLineMask = 1 << 3, } NSTableViewGridLineStyle;

    Constants

    • GridNone

      NSTableViewGridNone

      Specifies that no grid lines should be displayed.

      Available in OS X v10.3 and later.

    • solidVerticalGridLineMask

      NSTableViewSolidVerticalGridLineMask

      Specifies that vertical grid lines should be displayed.

      Available in OS X v10.3 and later.

    • solidHorizontalGridLineMask

      NSTableViewSolidHorizontalGridLineMask

      Specifies that horizontal grid lines should be displayed.

      Available in OS X v10.3 and later.

    • dashedHorizontalGridLineMask

      NSTableViewDashedHorizontalGridLineMask

      Specifies that the horizontal grid lines should be drawn dashed.

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • The following constants specify the autoresizing styles. These constants are used by the columnAutoresizingStyle property.

    Declaration

    Swift

    enum NSTableViewColumnAutoresizingStyle : UInt { case NoColumnAutoresizing case UniformColumnAutoresizingStyle case SequentialColumnAutoresizingStyle case ReverseSequentialColumnAutoresizingStyle case LastColumnOnlyAutoresizingStyle case FirstColumnOnlyAutoresizingStyle }

    Objective-C

    enum { NSTableViewNoColumnAutoresizing = 0, NSTableViewUniformColumnAutoresizingStyle, NSTableViewSequentialColumnAutoresizingStyle, NSTableViewReverseSequentialColumnAutoresizingStyle, NSTableViewLastColumnOnlyAutoresizingStyle, NSTableViewFirstColumnOnlyAutoresizingStyle }; typedef NSUInteger NSTableViewColumnAutoresizingStyle;

    Constants

    • noColumnAutoresizing

      NSTableViewNoColumnAutoresizing

      Disable table column autoresizing.

      Available in OS X v10.4 and later.

    • uniformColumnAutoresizingStyle

      NSTableViewUniformColumnAutoresizingStyle

      Autoresize all columns by distributing space equally, simultaneously.

      Available in OS X v10.4 and later.

    • sequentialColumnAutoresizingStyle

      NSTableViewSequentialColumnAutoresizingStyle

      Autoresize 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.

    • reverseSequentialColumnAutoresizingStyle

      NSTableViewReverseSequentialColumnAutoresizingStyle

      Autoresize 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.

    • lastColumnOnlyAutoresizingStyle

      NSTableViewLastColumnOnlyAutoresizingStyle

      Autoresize 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.

    • firstColumnOnlyAutoresizingStyle

      NSTableViewFirstColumnOnlyAutoresizingStyle

      Autoresize 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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The following constants specify the selection highlight styles. These constants are used by the selectionHighlightStyle property.

    Declaration

    Swift

    enum NSTableViewSelectionHighlightStyle : Int { case None case Regular case SourceList }

    Objective-C

    typedef enum NSTableViewSelectionHighlightStyle : NSInteger { NSTableViewSelectionHighlightStyleNone = -1, NSTableViewSelectionHighlightStyleRegular = 0, NSTableViewSelectionHighlightStyleSourceList = 1, } NSTableViewSelectionHighlightStyle;

    Constants

    • none

      NSTableViewSelectionHighlightStyleNone

      Displays no highlight style at all.

      Available in OS X v10.6 and later.

    • regular

      NSTableViewSelectionHighlightStyleRegular

      The regular highlight style of NSTableView. On OS X v10.7 a light blue (returned by sending NSColor a alternateSelectedControlColor message) or light gray color (returned by sending NSColor a secondarySelectedControlColor message).

      Available in OS X v10.5 and later.

    • sourceList

      NSTableViewSelectionHighlightStyleSourceList

      The source list style of NSTableView. On 10.5, a light blue gradient is used to highlight selected rows.

      Available in OS X v10.5 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Specifies the animation effects to apply when inserting or removing rows.

    Declaration

    Swift

    struct NSTableViewAnimationOptions : OptionSetType { init(rawValue rawValue: UInt) static var EffectNone: NSTableViewAnimationOptions { get } static var EffectFade: NSTableViewAnimationOptions { get } static var EffectGap: NSTableViewAnimationOptions { get } static var SlideUp: NSTableViewAnimationOptions { get } static var SlideDown: NSTableViewAnimationOptions { get } static var SlideLeft: NSTableViewAnimationOptions { get } static var SlideRight: NSTableViewAnimationOptions { get } }

    Objective-C

    typedef enum NSTableViewAnimationOptions : NSUInteger { NSTableViewAnimationEffectNone = 0x0, NSTableViewAnimationEffectFade = 0x1, NSTableViewAnimationEffectGap = 0x2, NSTableViewAnimationSlideUp = 0x10, NSTableViewAnimationSlideDown = 0x20, NSTableViewAnimationSlideLeft = 0x30, NSTableViewAnimationSlideRight = 0x40, } NSTableViewAnimationOptions;

    Constants

    • EffectNone

      NSTableViewAnimationEffectNone

      Use no animation effects.

      Available in OS X v10.7 and later.

    • effectFade

      NSTableViewAnimationEffectFade

      Use a fade for row or column removal. The effect can be combined with any of the slide constants.

      Available in OS X v10.7 and later.

    • effectGap

      NSTableViewAnimationEffectGap

      Creates 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.

    • slideUp

      NSTableViewAnimationSlideUp

      Animates a row insertion or removal by sliding upward.

      Available in OS X v10.7 and later.

    • slideDown

      NSTableViewAnimationSlideDown

      Animates a row insertion or removal by sliding downward.

      Available in OS X v10.7 and later.

    • slideLeft

      NSTableViewAnimationSlideLeft

      Animates 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.

    • slideRight

      NSTableViewAnimationSlideRight

      Animates 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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • The row size style constants define the size of the rows in the table view. They are used by the effectiveRowSizeStyle and rowSizeStyle properties. You can also query the row size in the NSTableCellView class’ property rowSizeStyle.

    Declaration

    Swift

    enum NSTableViewRowSizeStyle : Int { case Default case Custom case Small case Medium case Large }

    Objective-C

    typedef enum NSTableViewRowSizeStyle : NSInteger { NSTableViewRowSizeStyleDefault = -1, NSTableViewRowSizeStyleCustom = 0, NSTableViewRowSizeStyleSmall = 1, NSTableViewRowSizeStyleMedium = 2, NSTableViewRowSizeStyleLarge = 3, } NSTableViewRowSizeStyle;

    Constants

    • default

      NSTableViewRowSizeStyleDefault

      The table will use the system default layout size: small, medium or large.

      Available in OS X v10.7 and later.

    • custom

      NSTableViewRowSizeStyleCustom

      The table will use the rowHeight or invoke the delegate method tableView:heightOfRow:, if implemented. The cell layout is not changed.

      Available in OS X v10.7 and later.

    • small

      NSTableViewRowSizeStyleSmall

      The table will use a row height specified for a small table. It is required that the size be fully tested and supported if NSTableViewRowSizeStyleCustom is not used.

      Available in OS X v10.7 and later.

    • medium

      NSTableViewRowSizeStyleMedium

      The table will use a row height specified for a medium table. It is required that the size be fully tested and supported if NSTableViewRowSizeStyleCustom is not used.

      Available in OS X v10.7 and later.

    • large

      NSTableViewRowSizeStyleLarge

      The table will use a row height specified for a large table. It is required that the size be fully tested and supported if NSTableViewRowSizeStyleCustom is not used.

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • These constants define table row edges on which row actions are attached. They are used by the tableView:rowActionsForRow:edge: delegate method.

    Declaration

    Swift

    enum NSTableRowActionEdge : Int { case Leading case Trailing }

    Objective-C

    typedef enum NSTableViewRowSizeStyle : NSInteger { NSTableRowActionEdgeLeading, NSTableRowActionEdgeTrailing } NSTableRowActionEdge;

    Constants

    • leading

      NSTableRowActionEdgeLeading

      Denotes the leading, or left, edge of an table row view.

      Available in OS X v10.11 and later.

    • trailing

      NSTableRowActionEdgeTrailing

      Denotes the trailing, or right, edge of an table row view.

      Available in OS X v10.11 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.11 and later.

  • 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

    @"NSOldColumn"

    An NSNumber object containing the integer value of the column’s original index.

    @"NSNewColumn"

    An NSNumber object containing the integer value of the column’s present index.

    Declaration

    Swift

    let NSTableViewColumnDidMoveNotification: String

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Posted 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

    @"NSTableColumn"

    The column that was resized.

    @"NSOldWidth"

    An NSNumber containing the integer value of the column’s original width.

    Declaration

    Swift

    let NSTableViewColumnDidResizeNotification: String

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Posted 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.

    Declaration

    Swift

    let NSTableViewSelectionDidChangeNotification: String

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Posted as an NSTableView object's selection changes (while the mouse button is still down). Note that the notification is sent only for mouse events that change the table’s selection, not keyboard events. The notification object is the table view whose selection is changing. This notification does not contain a userInfo dictionary.

    Declaration

    Swift

    let NSTableViewSelectionIsChangingNotification: String

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.