Class

NSOutlineView

A view that uses a row-and-column format to display hierarchical data like directories and files that can be expanded and collapsed.

Declaration

@interface NSOutlineView : NSTableView

Overview

Like a table view, an outline view does not store its own data, instead it retrieves data values as needed from a data source to which it has a weak reference (see Delegates and Data Sources). See NSOutlineViewDataSource, which declares the methods that an NSOutlineView object uses to access the contents of its data source object.

An outline view has the following features:

  • A user can expand and collapse rows, edit values, and resize and rearrange columns.

  • Each item in the outline view must be unique. In order for the collapsed state to remain consistent between reloads the item's pointer must remain the same and the item must maintain isEqual: sameness.

  • The view gets data from a data source (see NSOutlineViewDataSource).

  • The view retrieves only the data that needs to be displayed.

For more information about using NSOutlineView in your app, see Navigating Hierarchical Data Using Outline and Split Views.

Subclassing

Subclassing NSOutlineView is not recommended. Customization can be accomplished in your data source class implementation (conforming to NSOutlineViewDataSource) or your delegate class implementation (conforming to NSOutlineViewDelegate).

Topics

Accessing the Data Source

dataSource

The object that provides the data displayed by the receiver.

stronglyReferencesItems

A Boolean value that indicates whether the outline view retains and releases the objects returned from its data source.

Working with Expandability

- isExpandable:

Returns a Boolean value that indicates whether a given item is expandable.

- isItemExpanded:

Returns a Boolean value that indicates whether a given item is expanded.

Expanding and Collapsing the Outline

- expandItem:

Expands a given item.

- expandItem:expandChildren:

Expands a specified item and, optionally, its children.

- collapseItem:

Collapses a given item.

- collapseItem:collapseChildren:

Collapses a given item and, optionally, its children.

Redisplaying Information

- reloadItem:

Reloads and redisplays the data for the given item.

- reloadItem:reloadChildren:

Reloads a given item and, optionally, its children.

Converting Between Items and Rows

- itemAtRow:

Returns the item associated with a given row.

- rowForItem:

Returns the row associated with a given item.

Working with the Outline Column

outlineTableColumn

The table column in which hierarchical data is displayed.

autoresizesOutlineColumn

A Boolean value that indicates whether the outline view resizes its outline column when the user expands or collapses items.

Working with Indentation

- levelForItem:

Returns the indentation level for a given item.

- levelForRow:

Returns the indentation level for a given row.

indentationPerLevel

The per-level indentation, measured in points.

indentationMarkerFollowsCell

A Boolean value indicating whether the indentation marker symbol displayed in the outline column should be indented along with the cell contents.

Working with Persistence

autosaveExpandedItems

A Boolean value indicating whether the expanded items are automatically saved across launches of the app.

Supporting Drag and Drop

- setDropItem:dropChildIndex:

Used to “retarget” a proposed drop.

- shouldCollapseAutoExpandedItemsForDeposited:

Returns a Boolean value that indicates whether auto-expanded items should return to their original collapsed state.

Getting Related Items

- parentForItem:

Returns the parent for a given item.

- childIndexForItem:

Returns the child index of the specified item within its parent.

- child:ofItem:

Returns the specified child of an item.

- numberOfChildrenOfItem:

Returns the number of children for the specified parent item.

Getting the Frame for a Cell

- frameOfOutlineCellAtRow:

Returns the frame of the outline cell for a given row.

Accessing the Delegate

delegate

The outline view’s delegate.

Manipulating Items

- insertItemsAtIndexes:inParent:withAnimation:

Inserts new items at the given indexes in the given parent with the specified optional animations.

- moveItemAtIndex:inParent:toIndex:inParent:

Moves an item at a given index in the given parent to a new index in a new parent.

- removeItemsAtIndexes:inParent:withAnimation:

Removes items at the given indexes in the given parent with the specified optional animations.

User Interface Layout Direction

userInterfaceLayoutDirection

The user interface layout direction.

Constants

Drop on Item Index

This constant defines an index that allows you to drop an item directly on a target.

Outline View Button Keys

These keys are used by the outline view to create disclosure buttons that collapse and expand items.

Notifications

NSOutlineViewColumnDidMoveNotification

Posted whenever a column is moved by user action in an NSOutlineView object.

NSOutlineViewColumnDidResizeNotification

Posted whenever a column is resized in an NSOutlineView object.

NSOutlineViewItemDidCollapseNotification

Posted whenever an item is collapsed in an NSOutlineView object.

NSOutlineViewItemDidExpandNotification

Posted whenever an item is expanded in an NSOutlineView object.

NSOutlineViewItemWillCollapseNotification

Posted before an item is collapsed (after the user clicks the arrow but before the item is collapsed).

NSOutlineViewItemWillExpandNotification

Posted before an item is expanded (after the user clicks the arrow but before the item is collapsed).

NSOutlineViewSelectionDidChangeNotification

Posted after the outline view's selection changes.

NSOutlineViewSelectionIsChangingNotification

Posted as the outline view’s selection changes (while the mouse button is still down).

Relationships

Inherits From

See Also

View

Navigating Hierarchical Data Using Outline and Split Views

Build a structured user interface that simplifies navigation in your app.