NSOutlineView does not update

I am trying to connect a view-based NSOutlineView to my model using NSTreeController and bindings.

My model consists of the main class Node (and its subclasses). Each Node can have 0 or more children. I store children in a C array (from Node objects) for performance reasons. I defined the properties childrenKeyPath, countKeyPathand of leafKeyPathmy NSTreeController, and implemented them in the Node class:

- (NSArray *)childNodes {
return [NSArray arrayWithObjects:children_ count:childCount_];
}

- (BOOL)nodeIsLeaf {
    return childCount_ < 1;
}

- (NSUInteger)childCount {
    return childCount_;
}

When I add a new child, I call [self willChangeValueForKey:@"childNodes"]before and [self didChangeValueForKey:@"childNodes"]after pasting it into array C.

, . ( NSTreeController Node. NSOutlineView NSTreeController. NSTextField objectValue.name NSTableViewCell)

( ) . .

, Node ( ), ( ), NSOutlineView ( ). Node will/didChangeValue, NSTreeController . 3 KeyPath .

, , , Node, Node, . NSTreeController , KVO children?

+3
1

, :

/* item is the item which has just had new children added */
[_outlineView reloadItem:[_outlineView parentForItem:item] reloadChildren:YES];

, Mountain Lion, . , , , 0 > 1 ( ?).

0

All Articles