Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOutlineView, NSTreeController and Sample Code "Source View"




On 17 Feb 2008, at 15:25, Ralph Manns wrote:

How can I add a ChildNode to a Node that is not selected in the OutlineView.

You have to use NSTreeController's -setSelectionIndexPath: and give it the index path of the object you want to add the child node to. Follwing this you can then add a node as you normally would.


Getting the index path of the node you want is the tricky part as NSTreeController still has no -indexPathForObject: that you can send it one of your Node objects and it will find it in the tree. I recommend having a look at Wil Shipley's blog post on the subject where he writes such a method as a category on NSTreeController.

http://www.wilshipley.com/blog/2006/04/pimp-my-code-part-10-whining-about.html

Alternatively you have to use -insertObject:atArrangedObjectIndexPath:

I've used this example code a lot, so feel free to ask away.

Jon
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSOutlineView, NSTreeController and Sample Code "Source View" (From: Ralph Manns <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.