• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTreeController - Remove Children
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: NSTreeController - Remove Children (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: sticky video/audio files in NSTextView with GC on
  • Next by Date: Re: Show Panel in another Application
  • Previous by thread: Re: NSTreeController - Remove Children
  • Next by thread: Writing kCFPreferencesAnyUser preferences by limited user
  • Index(es):
    • Date
    • Thread