Re: NSTreeController ChildKeyPath
Re: NSTreeController ChildKeyPath
- Subject: Re: NSTreeController ChildKeyPath
- From: "Marcus S. Zarra" <email@hidden>
- Date: Fri, 29 Jul 2005 10:29:34 -0600
I am unfortunately not at my OSX machine right now but this advise does not
sound right. As I recall there is a binding for leaf and another binding for
children. Two different things. The ChildKey binding expects to receive an
array of children back and the leaf binding expects to receive a Bool.
The tree controller expects to be dealing with one object as near as I can
tell. What I did to get it working for me was set up an abstract parent
object that both my branches and leaves extended from. This is assuming of
course that you have multiple types of objects you want the tree controller
to handle. The parent object has two methods: (Bool)isLeaf and (NSArray
*)children. The branch objects extended the parent, returned YES for isLeaf
and returned an NSArray of all of it's children. The leaf objects returned
NO for isLeaf and returned nil for children.
Hope this helps and let me know if anything doesn't make sense.
Marcus
On 7/29/05, Keith Blount <email@hidden> wrote:
>
> Hello,
>
> You just need a BOOL instance variable such as BOOL
> isLeaf, which is set to YES if you want the item to be
> a leaf, and NO if it is a group. Then in the
> NSTreeController's bindings, bind this variable to the
> Child Key Path.
>
> Not sure how this will help you find a specific object
> though. For finding specific objects you will probably
> need to write a recursive method that traverses the
> tree to find what you are looking for.
>
> Hope that is of some help.
> Cheers,
> Keith
>
> --- ORIGINAL MESSAGE: ---
>
> Can anyone explain in more detail than the apple
> documentation how
> the ChildKeyPath works for traversing a
> NSTreeController? I need to
> find a specific object, and it would appear this is
> how I do it.
> Each of my objects implements items (they return nil
> because every
> object is a leaf, i.e. no children).
>
> Thanks,
>
> Ben Dunton
>
>
>
> ____________________________________________________
> Start your day with Yahoo! - make it your home page
> http://www.yahoo.com/r/hs
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden