NSOutline objects support a data source delegate in addition to the regular delegate object. The
NSOutline protocol defines methods that the outline view invokes as necessary to retrieve data and information about the data from the data source delegate, and—optionally—to update data values.
- macOS 10.6+
All the methods in the
NSOutline protocol are marked as
@optional. While this is true, there are cases were you must implement some methods to achieve required functionality, specifically when working with conventional data sources rather than data that is provided by Cocoa bindings.
Required and Optional Methods Using Programmatic Conventions and Cocoa Bindings
If you are using conventional data sources for content you must implement the basic methods that provide the outline view with data:
outline. Applications that acquire their data using Cocoa bindings do not need to implement these methods.
Similarly, when using conventional data sources , if you want to allow the user to edit values, you must implement
outline. When these methods are invoked by the outline view,
nil as the
item refers to the “root” item.
NSOutline requires that each item in the outline view be unique. In order for the collapsed state of an outline view to remain consistent between reloads you must always return the same object for an item. When using Cocoa bindings to provide outline view content, there is no requirement to implement this method.