Hi Kyle,

Thanks for the assist, I have attempted to use childNodes (see the following 
code) and it works out fine ONLY the parent node itself also gets removed... 

Here's what I did:

int parentId = 1; //Some node I wanna empty
[treeController setSelectionIndexPath:[NSIndexPath 
indexPathWithIndex:parentId]];
        
NSTreeNode *node = [[treeController selectedNodes] objectAtIndex: 0];
NSMutableArray * ip = [[NSMutableArray alloc] init];
NSArray * nodes = [node childNodes];
        
// if I start i at 0, the "enclosing" node also gets removed. 
// Setting it at 1 doesn't remove it (and sucessfully removes the children).
// I don't get this, I thought I was dealing with only children?
for(int i=1; i<=[nodes count]; i++){
        [ip addObject:[[nodes objectAtIndex:0] indexPath]];
}
        
[treeController removeObjectsAtArrangedObjectIndexPaths:ip];


Any thoughts?

S.

> NSTreeNode has a -childNodes method.  I'd use that to
> recursively
> determine if each node has children, and then add those
> children to an
> array of index paths to be deleted.  Then it's a matter
> of
> -[NSTreeController
> removeObjectsAtArrangedObjectIndexPaths:].
> 
> --Kyle Sluder


      
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to