NSTreeController is a bindings compatible controller that manages a tree of objects. It 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.
- macOS 10.10+
NSTreeController object requires that you describe how the tree of objects is traversed by specifying the key-path for child objects specified by
childrenKeyPath. 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
countKeyPath) 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
leafKeyPath that specifies a key in your model object that returns
true if the object is a leaf node, and
false 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
NSTreeController from having to examine the child object to determine if it is a leaf node.