<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOutlineView",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOutlineView"
  },
  "title" : "NSOutlineView"
}
-->

# NSOutlineView

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

```
class NSOutlineView
```

## 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](https://developer.apple.com/library/archive/documentation/General/Conceptual/CocoaEncyclopedia/DelegatesandDataSources/DelegatesandDataSources.html#//apple_ref/doc/uid/TP40010810-CH11)). See [`NSOutlineViewDataSource`](/documentation/AppKit/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 <doc://com.apple.documentation/documentation/ObjectiveC/NSObjectProtocol/isEqual(_:)> sameness.
- The view gets data from a data source (see [`NSOutlineViewDataSource`](/documentation/AppKit/NSOutlineViewDataSource)).
- The view retrieves only the data that needs to be displayed.

> Important:
> It is possible that your data source methods for populating the outline view may be called before <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/awakeFromNib()> if the data source is specified in Interface Builder. You should defend against this by having the data source’s ``doc://com.apple.appkit/documentation/AppKit/NSOutlineViewDataSource/outlineView(_:numberOfChildrenOfItem:)`` method return `0` for the number of items when the data source has not yet been configured. In <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/awakeFromNib()>, when the data source is initialized you should always call ``doc://com.apple.appkit/documentation/AppKit/NSTableView/reloadData()``.

For more information about using NSOutlineView in your app, see [Navigating Hierarchical Data Using Outline and Split Views](/documentation/AppKit/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`](/documentation/AppKit/NSOutlineViewDataSource)) or your delegate class implementation (conforming to [`NSOutlineViewDelegate`](/documentation/AppKit/NSOutlineViewDelegate)).

## Topics

### Accessing the Data Source

[`dataSource`](/documentation/AppKit/NSOutlineView/dataSource)

The object that provides the data displayed by the receiver.

[`stronglyReferencesItems`](/documentation/AppKit/NSOutlineView/stronglyReferencesItems)

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

### Working with Expandability

[`isExpandable(_:)`](/documentation/AppKit/NSOutlineView/isExpandable(_:))

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

[`isItemExpanded(_:)`](/documentation/AppKit/NSOutlineView/isItemExpanded(_:))

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

### Expanding and Collapsing the Outline

[`expandItem(_:)`](/documentation/AppKit/NSOutlineView/expandItem(_:))

Expands a given item.

[`expandItem(_:expandChildren:)`](/documentation/AppKit/NSOutlineView/expandItem(_:expandChildren:))

Expands a specified item and, optionally, its children.

[`collapseItem(_:)`](/documentation/AppKit/NSOutlineView/collapseItem(_:))

Collapses a given item.

[`collapseItem(_:collapseChildren:)`](/documentation/AppKit/NSOutlineView/collapseItem(_:collapseChildren:))

Collapses a given item and, optionally, its children.

### Redisplaying Information

[`reloadItem(_:)`](/documentation/AppKit/NSOutlineView/reloadItem(_:))

Reloads and redisplays the data for the given item.

[`reloadItem(_:reloadChildren:)`](/documentation/AppKit/NSOutlineView/reloadItem(_:reloadChildren:))

Reloads a given item and, optionally, its children.

### Converting Between Items and Rows

[`item(atRow:)`](/documentation/AppKit/NSOutlineView/item(atRow:))

Returns the item associated with a given row.

[`row(forItem:)`](/documentation/AppKit/NSOutlineView/row(forItem:))

Returns the row associated with a given item.

### Working with the Outline Column

[`outlineTableColumn`](/documentation/AppKit/NSOutlineView/outlineTableColumn)

The table column in which hierarchical data is displayed.

[`autoresizesOutlineColumn`](/documentation/AppKit/NSOutlineView/autoresizesOutlineColumn)

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

### Working with Indentation

[`level(forItem:)`](/documentation/AppKit/NSOutlineView/level(forItem:))

Returns the indentation level for a given item.

[`level(forRow:)`](/documentation/AppKit/NSOutlineView/level(forRow:))

Returns the indentation level for a given row.

[`indentationPerLevel`](/documentation/AppKit/NSOutlineView/indentationPerLevel)

The per-level indentation, measured in points.

[`indentationMarkerFollowsCell`](/documentation/AppKit/NSOutlineView/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`](/documentation/AppKit/NSOutlineView/autosaveExpandedItems)

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

### Supporting Drag and Drop

[`setDropItem(_:dropChildIndex:)`](/documentation/AppKit/NSOutlineView/setDropItem(_:dropChildIndex:))

Used to “retarget” a proposed drop.

[`shouldCollapseAutoExpandedItems(forDeposited:)`](/documentation/AppKit/NSOutlineView/shouldCollapseAutoExpandedItems(forDeposited:))

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

### Getting Related Items

[`parent(forItem:)`](/documentation/AppKit/NSOutlineView/parent(forItem:))

Returns the parent for a given item.

[`childIndex(forItem:)`](/documentation/AppKit/NSOutlineView/childIndex(forItem:))

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

[`child(_:ofItem:)`](/documentation/AppKit/NSOutlineView/child(_:ofItem:))

Returns the specified child of an item.

[`numberOfChildren(ofItem:)`](/documentation/AppKit/NSOutlineView/numberOfChildren(ofItem:))

Returns the number of children for the specified parent item.

### Getting the Frame for a Cell

[`frameOfOutlineCell(atRow:)`](/documentation/AppKit/NSOutlineView/frameOfOutlineCell(atRow:))

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

### Accessing the Delegate

[`delegate`](/documentation/AppKit/NSOutlineView/delegate)

The outline view’s delegate.

### Manipulating Items

[`insertItems(at:inParent:withAnimation:)`](/documentation/AppKit/NSOutlineView/insertItems(at:inParent:withAnimation:))

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

[`moveItem(at:inParent:to:inParent:)`](/documentation/AppKit/NSOutlineView/moveItem(at:inParent:to:inParent:))

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

[`removeItems(at:inParent:withAnimation:)`](/documentation/AppKit/NSOutlineView/removeItems(at:inParent:withAnimation:))

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

### User Interface Layout Direction

[`userInterfaceLayoutDirection`](/documentation/AppKit/NSOutlineView/userInterfaceLayoutDirection)

The user interface layout direction.

### Constants

[Drop on Item Index](/documentation/AppKit/drop-on-item-index)

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

[Outline View Button Keys](/documentation/AppKit/outline-view-button-keys)

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

### Notifications

[`columnDidMoveNotification`](/documentation/AppKit/NSOutlineView/columnDidMoveNotification)

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

[`columnDidResizeNotification`](/documentation/AppKit/NSOutlineView/columnDidResizeNotification)

Posted whenever a column is resized in an `NSOutlineView` object.

[`itemDidCollapseNotification`](/documentation/AppKit/NSOutlineView/itemDidCollapseNotification)

Posted whenever an item is collapsed in an `NSOutlineView` object.

[`itemDidExpandNotification`](/documentation/AppKit/NSOutlineView/itemDidExpandNotification)

Posted whenever an item is expanded in an `NSOutlineView` object.

[`itemWillCollapseNotification`](/documentation/AppKit/NSOutlineView/itemWillCollapseNotification)

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

[`itemWillExpandNotification`](/documentation/AppKit/NSOutlineView/itemWillExpandNotification)

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

[`selectionDidChangeNotification`](/documentation/AppKit/NSOutlineView/selectionDidChangeNotification)

Posted after the outline view’s selection changes.

[`selectionIsChangingNotification`](/documentation/AppKit/NSOutlineView/selectionIsChangingNotification)

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



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)