Next Page > Hide TOC

NSTableColumn Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in Mac OS X v10.0 and later.
Companion guide
Declared in
NSTableColumn.h
Related sample code

Overview

An NSTableColumn stores the display characteristics and attribute identifier for a column in an NSTableView. The NSTableColumn determines the width and width limits, resizability, and editability of its column in the NSTableView. It also stores 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 NSCells. For example, you can use the default NSTextFieldCell for displaying string values or substitute an NSImageCell to display pictures.

Adopted Protocols

NSCoding

Tasks

Creating an NSTableColumn

Setting the NSTableView

Controlling Size

Setting Component Cells

Setting the Identifier

Controlling Editability

Sorting

Setting Column Visibility

Setting Tool Tips

Deprecated Methods

Instance Methods

dataCell

Returns the NSCell object used by the NSTableView to draw values for the receiver.

- (id)dataCell

Availability
See Also
Declared In
NSTableColumn.h

dataCellForRow:

Returns the NSCell object used by the NSTableView to draw values for the receiver.

- (id)dataCellForRow:(NSInteger)row

Discussion

NSTableView always calls this method. By default, this method just calls dataCell. Subclassers can override if they need to potentially use different cells for different rows. 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
Declared In
NSTableColumn.h

headerCell

Returns the NSTableHeaderCell object used to draw the header of the receiver.

- (id)headerCell

Discussion

You can set the column title by sending setStringValue: to this object.

Availability
See Also
Related Sample Code
Declared In
NSTableColumn.h

headerToolTip

Returns the tooltip string that is displayed when the cursor pauses over the header cell of the receiver.

- (NSString *)headerToolTip

Return Value

The tooltip displayed when the cursor pauses over the header cell of the receiver.

Availability
See Also
Declared In
NSTableColumn.h

identifier

Returns the object used by the data source to identify the attribute corresponding to the receiver.

- (id)identifier

Availability
See Also
Related Sample Code
Declared In
NSTableColumn.h

initWithIdentifier:

Initializes a newly created NSTableColumn with identifier as its identifier and with an NSTextFieldCell as its data cell.

- (id)initWithIdentifier:(id)identifier

Discussion

Send setStringValue: to the header cell to set the column title. This method is the designated initializer for the NSTableColumn class. Returns an initialized object.

See the NSTableView class specification for information on identifiers.

Availability
See Also
Declared In
NSTableColumn.h

isEditable

Returns YES if the user can edit cells associated with the receiver by double-clicking the column in the NSTableView, NO otherwise.

- (BOOL)isEditable

Discussion

You can initiate editing programmatically regardless of this setting with NSTableView’s editColumn:row:withEvent:select: method.

Availability
See Also
Declared In
NSTableColumn.h

isHidden

Returns a Boolean value that indicates whether the receiver is hidden.

- (BOOL)isHidden

Return Value

YES if the receiver is hidden, otherwise NO.

Availability
See Also
Declared In
NSTableColumn.h

isResizable

Returns YES if the user is allowed to resize the receiver in its NSTableView, NO otherwise.

- (BOOL)isResizable

Discussion

You can change the size programmatically regardless of this setting.

This method is deprecated. You should use resizingMask instead.

Availability
See Also
Declared In
NSTableColumn.h

maxWidth

Returns the maximum width of the receiver.

- (CGFloat)maxWidth

Discussion

The receiver’s width can’t be made larger than this size either by the user or programmatically.

Availability
See Also
Declared In
NSTableColumn.h

minWidth

Returns the minimum width for the receiver.

- (CGFloat)minWidth

Discussion

The receiver’s width can’t be made less than this size either by the user or programmatically.

Availability
See Also
Declared In
NSTableColumn.h

resizingMask

Returns the receiver’s resizing mask.

- (NSUInteger)resizingMask

Discussion

See “Resizing Modes” for a description of the resizing mask constants.

Availability
See Also
Declared In
NSTableColumn.h

setDataCell:

Sets the NSCell used by the NSTableView to draw individual values for the receiver to aCell.

- (void)setDataCell:(NSCell *)aCell

Discussion

You can use this method to control the font, alignment, and other text attributes for an NSTableColumn. You can also assign a cell to display things other than text—for example, an NSImageCell to display images.

Availability
See Also
Related Sample Code
Declared In
NSTableColumn.h

setEditable:

Controls whether the user can edit cells in the receiver by double-clicking them.

- (void)setEditable:(BOOL)flag

Discussion

If flag is YES a double click initiates editing; if flag is NO it merely sends the double-click action to the NSTableView’s target. You can initiate editing programmatically regardless of this setting with NSTableView’s editColumn:row:withEvent:select: method.

Availability
See Also
Related Sample Code
Declared In
NSTableColumn.h

setHeaderCell:

Sets the NSCell used to draw the receiver’s header to aCell.

- (void)setHeaderCell:(NSCell *)aCell

Discussion

aCell should never be nil.

Availability
See Also
Declared In
NSTableColumn.h

setHeaderToolTip:

Sets the tooltip string that is displayed when the cursor pauses over the header cell of the receiver.

- (void)setHeaderToolTip:(NSString *)string

Parameters
string

A string that functions as the tooltip for the header cell of the receiver.

Availability
See Also
Declared In
NSTableColumn.h

setHidden:

Sets whether the receiver is hidden.

- (void)setHidden:(BOOL)hidden

Parameters
hidden

YES if the receiver is to be hidden, otherwise NO.

Discussion

Columns which are hidden still exist in the tableview’s tableColumns array and are included in the tableview’s numberOfColumns count.

The hidden state of the receiver is stored when the tableview autosaves the NSTableColumn state.

Availability
See Also
Declared In
NSTableColumn.h

setIdentifier:

Sets the receiver’s identifier to anObject.

- (void)setIdentifier:(id)anObject

Discussion

This object is used by the data source to identify the attribute corresponding to the NSTableColumn.

Availability
See Also
Related Sample Code
Declared In
NSTableColumn.h

setMaxWidth:

Sets the receiver’s maximum width to maxWidth, also adjusting the current width if it’s greater than this value.

- (void)setMaxWidth:(CGFloat)maxWidth

Discussion

The NSTableView can be made no wider than this size, either by the user or programmatically.

Availability
See Also
Declared In
NSTableColumn.h

setMinWidth:

Sets the receiver’s minimum width to minWidth, also adjusting the current width if it’s less than this value.

- (void)setMinWidth:(CGFloat)minWidth

Discussion

The NSTableView can be made no less wide than this size, either by the user or programmatically.

Availability
See Also
Declared In
NSTableColumn.h

setResizable:

Sets whether the user can resize the receiver in its NSTableView.

- (void)setResizable:(BOOL)flag

Discussion

If flag is YES the user can resize the receiver; if flag is NO the user can’t resize it. You can always set the size programmatically.

This method is deprecated. You should use setResizingMask: instead.

Availability
See Also
Declared In
NSTableColumn.h

setResizingMask:

Sets the resizing mask for the receiver to resizingMask.

- (void)setResizingMask:(NSUInteger)resizingMask

Discussion

If resizingMask is 0, the column is not resizable. See “Resizing Modes” for the appropriate mask values.

Availability
See Also
Declared In
NSTableColumn.h

setSortDescriptorPrototype:

Sets the receiver’s sort descriptor prototype.

- (void)setSortDescriptorPrototype:(NSSortDescriptor *)sortDescriptor

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
See Also
Declared In
NSTableColumn.h

setTableView:

Sets aTableView as the receiver’s NSTableView.

- (void)setTableView:(NSTableView *)aTableView

Discussion

You should never need to invoke this method; it’s invoked automatically when you add an NSTableColumn to an NSTableView.

Availability
See Also
Declared In
NSTableColumn.h

setWidth:

Sets the receiver’s width to newWidth.

- (void)setWidth:(CGFloat)newWidth

Discussion

If newWidth exceeds the minimum or maximum width, it’s adjusted to the appropriate limiting value. Marks the NSTableView as needing display.

This method posts NSTableViewColumnDidResizeNotification on behalf of the receiver’s NSTableView.

Availability
See Also
Related Sample Code
Declared In
NSTableColumn.h

sizeToFit

Resizes the receiver to fit the width of its header cell.

- (void)sizeToFit

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 as needing display if the width actually changes.

Availability
See Also
Related Sample Code
Declared In
NSTableColumn.h

sortDescriptorPrototype

Returns the receiver’s sort descriptor prototype.

- (NSSortDescriptor *)sortDescriptorPrototype

Availability
See Also
Declared In
NSTableColumn.h

tableView

Returns the NSTableView the receiver belongs to.

- (NSTableView *)tableView

Availability
See Also
Declared In
NSTableColumn.h

width

Returns the width of the receiver.

- (CGFloat)width

Availability
Declared In
NSTableColumn.h

Constants

Resizing Modes

These constants specify the resizing modes available for the table column. You specify either NSTableColumnNoResizing or a resizing mask created using the C bitwise OR operator. These values are then passed as the parameter to the setResizingMask: method.

enum {     NSTableColumnNoResizing = 0,
   NSTableColumnAutoresizingMask = ( 1 << 0 ),
   NSTableColumnUserResizingMask = ( 1 << 1 ),
};

Constants
NSTableColumnNoResizing

Prevents the table column from resizing.

Available in Mac OS X v10.4 and later.

Declared in NSTableColumn.h.

NSTableColumnAutoresizingMask

Allows the table column to resize automatically in response to resizing the tableview. Enabling this option is the same as enabling the "Live Resizable" option in Interface Builder. The resizing behavior for the table view is set using the NSTableView method setColumnAutoresizingStyle:.

Available in Mac OS X v10.4 and later.

Declared in NSTableColumn.h.

NSTableColumnUserResizingMask

Allows the table column to be resized explicitly by the user. Enabling this option is the same as enabling the "User Resizable" option in Interface Builder.

Available in Mac OS X v10.4 and later.

Declared in NSTableColumn.h.

Declared In
NSTableColumn.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-31)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.