Creating and Using Tree Structures

Beta documentation : This document has not received a full technical review and therefore might contain inaccuracies.

With Collection Services CFTree type you can create tree structures in memory to represent hierarchical organizations of information. In such structures, each tree node has exactly one parent tree (except for the root tree, which has no parent) and can have multiple child trees. Each CFTree object in the extended structure has a context associated with it; this context includes some program-defined data as well as callbacks that operate on that data. The program-defined data is often used as the basis for determining where CFTree objects fit within the structure.

This section discusses how to create CFTree objects, fit them into the structure of trees, and then later find, get, and modify them. The first parameter of most CFTree functions is a reference to a parent CFTree object; the operation itself usually involves one or more children of that parent. In other words, most CFTree routines work "down" the hierarchy from a given parent but affect only the children of that parent.

One important fact to remember with working with CFTree objects is that functions that operate on children are not recursive. They affect only the immediate child trees. If you want to traverse all subtrees from any given parent node, your code must supply the traversal logic.

Creating a CFTree Object

Adding a Tree to its Parent

Getting Child Trees

Other Operations With CFTree Structures


© 1999 Apple Computer, Inc. – (Last Updated 07 September 99)