Re: NSOutlineView, NSTreeController and Sample Code "Source View"
Subject : Re: NSOutlineView, NSTreeController and Sample Code "Source View"
From: Jonathan Dann <email@hidden >
Date: Sun, 17 Feb 2008 17:38:21 +0000
Delivered-to: email@hidden
Delivered-to: email@hidden
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer; bh=j+4IlNMdo9VOe7FhSx7nqdbspwuJsQbxO+8Y5U1+Es0=; b=TiJzzmB53bcgVWL+GlE04a11+29PSNVXQo+YJhRB607Ks9P7t79XEui/14sJHeLSG7+nNY5zxQC/8qIzOw83FWGN9CYEr+6RVRFdyrmpCqak2SjHraEbtMNK5Hyl854AKjb+ldVPYfXGteXN/IR6Ko+f7v88aMsfGDsfdtKN62A=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer; b=VY8r5nAU5mKWcoVnby3JvAtqT5qHd8zG+jLg43ymGzfR2ZRL/RfdxVK/3fthqINdv/12ZGke2SXGw3NHxwPYLaZRgQsM+HPIDW72mJn7azUvlJhNAaKaj/nCVNHK15gJMc6mqBdvz975Y6C2KgVekL+/KxANChaDKEYQ5LdVPnM=
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
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.