Using an Outline View Delegate

The NSOutlineViewDelegate protocol gives the delegate control over the appearance of individual cells in the table, over changes in selection, and over editing of cells.

Delegate methods that request permission to alter the selection or edit a value are invoked during user actions that affect the outline view, but are not invoked by programmatic changes to the view. When making changes programmatically, you decide whether you want the delegate to intervene and, if so, you send the appropriate message (checking first that the delegate responds to that message). Because the delegate methods involve the actual data displayed by the outline view, the delegate is typically the same object as the data source, though this is not a requirement.

The NSOutlineViewDelegate protocol defines these delegate messages:

The NSOutlineViewDelegate protocol defines these additional delegate messages:

In addition to these methods, the delegate protocol is automatically registered to receive messages corresponding to NSOutlineView notifications. These inform the delegate when the selection changes or is about to change, when a column is moved or resized, and when an item is expanded or collapsed:

Delegate Message

Notification

outlineViewColumnDidMove:

NSOutlineViewColumnDidMoveNotification

outlineViewColumnDidResize:

NSOutlineViewColumnDidResizeNotification

outlineViewSelectionDidChange:

NSOutlineViewSelectionDidChangeNotification

outlineViewSelectionIsChanging:

NSOutlineViewSelectionIsChangingNotification

outlineViewItemDidExpand:

NSOutlineViewItemDidExpandNotification

outlineViewItemDidCollapse:

NSOutlineViewItemDidCollapseNotification