NSTableColumn Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSTableColumn.h |
Overview
The NSTableColumn class stores the display characteristics and attribute identifier for a column in an NSTableView instance. The table column determines the width and width limits, resizing and editing of its column in the table view.
Table columns also store two NSCell objects: the header cell, which is used to draw the column header, and the data cell, used to draw the values for each row. You can control the display of the column by setting the subclasses of NSCell used and by setting the font and other display characteristics for these cells. For example, you can use an NSTextFieldCell for displaying string values or substitute an NSImageCell to display pictures.
Tasks
Creating an NSTableColumn
Setting the NSTableView
Controlling Size
-
– setWidth: -
– width -
– setMinWidth: -
– minWidth -
– setMaxWidth: -
– maxWidth -
– setResizingMask: -
– resizingMask -
– sizeToFit
Setting Component Cells
Setting the Identifier
Controlling Editability
Sorting
Setting Column Visibility
Setting Tool Tips
Deprecated Methods
-
– isResizableDeprecated in OS X v10.4 -
– setResizable:Deprecated in OS X v10.4
Instance Methods
dataCell
Returns the cell prototype object used to draw individual cells.
Return Value
The NSCell subclass used as the prototype for table column cells.
Discussion
When using a cell-based table view with Cocoa bindings the bindings infrastructure may directly call this method to access bindings and properties set on the cell.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hdataCellForRow:
Returns the cell instance used to display values in the specified row of the table column.
Parameters
- row
The table column row.
Return Value
The data cell instance.
Discussion
NSTableView always calls this method. By default, this method just calls dataCell.
Subclassers can override this method if they need to use different cell types for different rows in a column. Subclasses should expect this method to be invoked with row equal to –1 in cases where no actual row is involved but the table view needs to get some generic cell info.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableColumn.hheaderCell
Returns the cell used to draw the table column’s header.
Return Value
The header cell
Discussion
You can set the table column title by sending setStringValue: to this object.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hheaderToolTip
Returns the tooltip string that is displayed when the cursor hovers over the header cell.
Return Value
The tooltip displayed when the cursor pauses over the header cell of the receiver.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTableColumn.hidentifier
Returns the identifier string.
Return Value
The table column identifier string.
Discussion
This string is used by the data source to identify the attribute corresponding to the table column.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hinitWithIdentifier:
Initializes a newly created table column with a string identifier.
Parameters
- identifier
The string identifier for the column.
Return Value
An initialized table column instance with an NSTextFieldCell instance as its default cell.
Discussion
You can send the setStringValue: message to the column’s headerCell to set the column title.
This method is the designated initializer for the NSTableColumn class.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hisEditable
Returns whether the table column cells are user editable.
Return Value
YES if the user can edit cells by double-clicking the cell in the table column; NO otherwise.
Discussion
You can initiate editing programmatically regardless of this setting with NSTableView’s editColumn:row:withEvent:select: method.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hisHidden
Returns whether the table column is hidden.
Return Value
YES if the table column is hidden; NO otherwise.
Discussion
The hidden state of the receiver is stored when the tableview autosaves the table column state.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTableColumn.hmaxWidth
Returns the maximum width of the table column.
Return Value
The maximum width of the table column, in points.
Availability
- Available in OS X v10.0 and later.
See Also
-
– minWidth -
– width -
– setMaxWidth: -
autoresizesAllColumnsToFit(NSTableView)
Declared In
NSTableColumn.hminWidth
Returns the table column’s minimum width.
Return Value
The table column width, in points.
Availability
- Available in OS X v10.0 and later.
See Also
-
– maxWidth -
– width -
– setMinWidth: -
autoresizesAllColumnsToFit(NSTableView)
Declared In
NSTableColumn.hresizingMask
Returns the table column’s resizing mask.
Return Value
Returns the resizing mask.
Discussion
See “Resizing Modes” for a description of the resizing mask constants.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTableColumn.hsetDataCell:
Sets the cell prototype used by the table column to draw individual cells.
Parameters
- aCell
A cell to use as the data cell.
Discussion
You can use this method to control the font, alignment, and other text attributes for the table column.
You can also assign a cell to display things other than text—for example, an to display images by setting the cell to NSImageCell.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hsetEditable:
Sets whether the user can edit cells in the table column.
Parameters
Discussion
You can initiate editing programmatically regardless of this setting using the NSTableView editColumn:row:withEvent:select: method.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hsetHeaderCell:
Sets the cell used to draw the table columns header.
Parameters
- aCell
The cell to use as the table column header. This value must not be
nil.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hsetHeaderToolTip:
Sets the tooltip string that is displayed when the cursor hovers over the header cell.
Parameters
- string
A string that functions as the tooltip for the header cell of the receiver.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTableColumn.hsetHidden:
Sets whether the table column is hidden.
Parameters
- aFlag
YESif the receiver is to be hidden;NOotherwise.
Discussion
Columns which are hidden still exist in the NSTableView instance’s tableColumns array and are included in the NSTableView instance’s numberOfColumns count.
The hidden state of the receiver is stored when the tableview autosaves the table column state.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTableColumn.hsetIdentifier:
Sets the table column’s identifier to the specified string..
Parameters
- aString
The column identifier string.
Discussion
This string is used by the data source to identify the attribute corresponding to the table column.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hsetMaxWidth:
Sets the table column’s maximum width
Parameters
- maxWidth
The maximum table column width, in points.
Discussion
If the table column’s current width is greater than maxWidth, the width is set to the maxWidth value.
The table column width can’t be greater than this value, whether dragged by the user or being set programmatically.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setMinWidth: -
– setWidth: -
– maxWidth -
autoresizesAllColumnsToFit(NSTableView)
Declared In
NSTableColumn.hsetMinWidth:
Sets the table column’s minimum width.
Parameters
- minWidth
The minimum table column width, in points.
Discussion
If the table column’s current width is less than minWidth, the width is set to the minWidth value.
The table column width can’t be less than this value, whether dragged by the user or being set programmatically.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setMaxWidth: -
– setWidth: -
– minWidth -
autoresizesAllColumnsToFit(NSTableView)
Declared In
NSTableColumn.hsetResizingMask:
Sets the resizing mask for the table column.
Parameters
- resizingMask
The resizing mask. See
“Resizing Modes”for the possible values. Values can be combined using the C bitwise OR operator. If resizingMask is0, the column is not resizable.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTableColumn.hsetSortDescriptorPrototype:
Sets the table column sort descriptor prototype.
Parameters
- sortDescriptor
The sort descriptor prototype.
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.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTableColumn.hsetTableView:
Sets the table view that contains the table column.
Parameters
- aTableView
The table view.
Discussion
You should never need to invoke this method; it’s invoked automatically when you add a table column to a table view using the NSTableView class’s method addTableColumn:.
Availability
- Available in OS X v10.0 and later.
See Also
-
– tableView -
addTableColumn:(NSTableView)
Declared In
NSTableColumn.hsetWidth:
Sets the table column’s width to the specified value.
Parameters
- newWidth
The new column width, in points.
Discussion
If newWidth exceeds the minimum or maximum width, it’s adjusted to the appropriate limiting value.
This method posts NSTableViewColumnDidResizeNotification on behalf of the table column’s NSTableView and marks the table view as needing display.
Availability
- Available in OS X v10.0 and later.
See Also
-
– width -
– setMinWidth: -
– setMaxWidth: -
autoresizesAllColumnsToFit(NSTableView)
Declared In
NSTableColumn.hsizeToFit
Resizes the table column to fit the width of its header cell.
Discussion
If the maximum width is less than the width of the header, the maximum is increased to the header’s width. Similarly, if the minimum width is greater than the width of the header, the minimum is reduced to the header’s width.
Marks the NSTableView instance containing the table column’s as needing display if the width actually changes.
Availability
- Available in OS X v10.0 and later.
See Also
-
– width -
– minWidth -
– maxWidth -
autoresizesAllColumnsToFit(NSTableView)
Declared In
NSTableColumn.hsortDescriptorPrototype
Returns the table column’s sort descriptor prototype.
Return Value
The sort descriptor prototype.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTableColumn.htableView
Returns the NSTableView the receiver belongs to.
Return Value
The NSTableView instance that contains the table column.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTableColumn.hwidth
Returns the table column’s width.
Return Value
The width of the table column, in points.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTableColumn.hConstants
Resizing Modes
These constants specify the resizing modes for a table column. These values are then passed as the parameter to the setResizingMask: method.
enum {
NSTableColumnNoResizing = 0,
NSTableColumnAutoresizingMask = ( 1 << 0 ),
NSTableColumnUserResizingMask = ( 1 << 1 )
};
Constants
NSTableColumnNoResizingPrevents the table column from resizing.
Available in OS X v10.4 and later.
Declared in
NSTableColumn.h.NSTableColumnAutoresizingMaskAllows the table column to resize automatically in response to resizing the table view. The resizing behavior for the table view is set using the
NSTableViewmethodsetColumnAutoresizingStyle:.Available in OS X v10.4 and later.
Declared in
NSTableColumn.h.NSTableColumnUserResizingMaskAllows the table column to be resized explicitly by the user.
Available in OS X v10.4 and later.
Declared in
NSTableColumn.h.
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-07-23)