NSTreeNode Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.5 and later. |
| Companion guide | |
| Declared in | NSTreeNode.h |
Overview
NSTreeNode simplifies the creation and management of trees of objects. Each tree node represents a model object. A tree node with nil as its parent node is considered the root of the tree.
Tasks
Creating Tree Nodes
Getting Information About a Node
-
– representedObject -
– indexPath -
– isLeaf -
– childNodes -
– mutableChildNodes -
– descendantNodeAtIndexPath: -
– parentNode
Sorting the Subtree
Class Methods
treeNodeWithRepresentedObject:
Creates and returns a tree node that represents the specified object.
Parameters
- modelObject
The object the tree node represents.
Return Value
An initialized tree node that represents modelObject.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.hInstance Methods
childNodes
Returns an array containing receiver’s child nodes.
Return Value
An array containing the receiver’s child nodes.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.hdescendantNodeAtIndexPath:
Returns the receiver’s descendent at the specified index path.
Parameters
- indexPath
An index path specifying a descendent of the receiver.
Return Value
A tree node, or nil if the node does not exist.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.hindexPath
Returns the position of the receiver relative to its root parent.
Return Value
An index path that represents the receiver’s position relative to the tree’s root node.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.hinitWithRepresentedObject:
Initializes a newly allocated tree node that represents the specified object.
Parameters
- modelObject
The object the tree node represents.
Return Value
An initialized tree node that represents modelObject.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.hisLeaf
Returns whether the receiver is a leaf node.
Return Value
YES if the receiver is a leaf node (has no child nodes), otherwise NO.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.hmutableChildNodes
Returns a mutable array that provides read-write access to the receiver’s child nodes.
Return Value
A mutable array that provides read-write access to the receiver’s child nodes.
Discussion
Nodes that are inserted into this array have their parent nodes set to the receiver. Nodes that are removed from this array automatically have their parent node set to nil. The array that is returned is observable using key-value observing.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.hparentNode
Returns the receiver’s parent node.
Return Value
The receiver’s parent node.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.hrepresentedObject
Returns the object the tree node represents.
Return Value
The object the tree node represents.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.hsortWithSortDescriptors:recursively:
Sorts the receiver’s subtree using the values of the represented objects with the specified sort descriptors.
Parameters
- sortDescriptors
Array of sort descriptors specifying how to sort the represented objects.
- recursively
A Boolean that specifies whether the child nodes should be sorted recursively.
Discussion
All the represented objects in the child nodes must be key-value coding compliant for the keys specified in the sort descriptors.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTreeNode.h© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-13)