27 id _representedObject;
33 + (id)treeNodeWithRepresentedObject:(
id)anObject
38 - (id)initWithRepresentedObject:(
id)anObject
44 _representedObject = anObject;
53 return [_childNodes count] <= 0;
58 return [_childNodes copy];
66 - (void)insertObject:(
id)aTreeNode inChildNodesAtIndex:(CPInteger)anIndex
68 [[aTreeNode._parentNode mutableChildNodes] removeObjectIdenticalTo:aTreeNode];
70 aTreeNode._parentNode =
self;
72 [_childNodes insertObject:aTreeNode atIndex:anIndex];
75 - (void)removeObjectFromChildNodesAtIndex:(CPInteger)anIndex
77 [_childNodes objectAtIndex:anIndex]._parentNode = nil;
79 [_childNodes removeObjectAtIndex:anIndex];
82 - (void)replaceObjectFromChildNodesAtIndex:(CPInteger)anIndex withObject:(
id)aTreeNode
84 var oldTreeNode = [_childNodes objectAtIndex:anIndex];
86 oldTreeNode._parentNode = nil;
87 aTreeNode._parentNode =
self;
89 [_childNodes replaceObjectAtIndex:anIndex withObject:aTreeNode];
92 - (id)objectInChildNodesAtIndex:(CPInteger)anIndex
94 return _childNodes[anIndex];
97 - (void)sortWithSortDescriptors:(CPArray)sortDescriptors recursively:(BOOL)shouldSortRecursively
99 [_childNodes sortUsingDescriptors:sortDescriptors];
101 if (!shouldSortRecursively)
104 var count = [_childNodes count];
107 [_childNodes[count] sortWithSortDescriptors:sortDescriptors recursively:YES];
113 count = [indexPath
length],
116 for (; index < count; ++index)
117 node = [node objectInChildNodesAtIndex:[indexPath indexAtPosition:index]];
136 _representedObject = [aCoder decodeObjectForKey:CPTreeNodeRepresentedObjectKey];
137 _parentNode = [aCoder decodeObjectForKey:CPTreeNodeParentNodeKey];
138 _childNodes = [aCoder decodeObjectForKey:CPTreeNodeChildNodesKey];
146 [aCoder encodeObject:_representedObject forKey:CPTreeNodeRepresentedObjectKey];
147 [aCoder encodeConditionalObject:_parentNode forKey:CPTreeNodeParentNodeKey];
148 [aCoder encodeObject:_childNodes forKey:CPTreeNodeChildNodesKey];
158 - (id)representedObject
160 return _representedObject;
id initWithRepresentedObject:(id anObject)
var CPTreeNodeParentNodeKey
id mutableArrayValueForKey:(id aKey)
var CPTreeNodeRepresentedObjectKey
Defines methods for use when archiving & restoring (enc/decoding).
var CPTreeNodeChildNodesKey