A bindings-compatible controller that manages a tree of objects.
- macOS 10.4+
NSTree class provides selection and sort management. Its primary purpose is to act as the controller when binding
NSBrowser instances to a hierarchical collection of objects. The root content object of the tree can be a single object, or an array of objects.
NSTree object requires that you describe how the tree of objects is traversed by specifying the key-path for child objects specified by
children. All child objects for the tree must be key-value coding compliant for the same child key path. If necessary, you should add properties to your model classes that map the child key name to the appropriate class-specific property name.
Child objects can implement a count method (specified to the tree controller using
count) that, if provided, returns the number of child objects available. Your model objects are expected to update the value of the count key path in a key-value observing compliant method. Optionally, you can also provide a leaf key path using
leaf that specifies a key in your model object that returns
YES if the object is a leaf node, and
NO if it is not. Changes to the leaf node value of the child object should be made in a key-value observing compliant manner. Providing the leaf node key path can improve performance, because it prevents the
NSTree from having to examine the child object to determine if it is a leaf node.
For more information about using NSTreeController in your app, see Navigating Hierarchical Data Using Outline and Split Views.