Re: NSTreeController - Remove Children
Re: NSTreeController - Remove Children
- Subject: Re: NSTreeController - Remove Children
- From: none given <email@hidden>
- Date: Tue, 17 Feb 2009 02:24:23 -0800 (PST)
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 (email@hidden)
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:
This email sent to email@hidden