Re: NSTreeController - please help, can't see the forest for the tree controller
Re: NSTreeController - please help, can't see the forest for the tree controller
- Subject: Re: NSTreeController - please help, can't see the forest for the tree controller
- From: Keith Blount <email@hidden>
- Date: Wed, 22 Jun 2005 14:15:20 -0700 (PDT)
Many thanks for the reply, much appreciated.
> It sounds like you'd want to subclass
> nstreecontroller and provide
> those actions.
> In the methods you provide, create your entity and
> set the leaf
> keypath to the appropriate value.
Thanks - this definitely seems the way to go. What I
have tried so far is in my subclass adding the
following method:
- (void)addLeaf:(id)sender
{
// Create the model object
KBNode *node = [[KBNode alloc] initLeaf];
// Insert it
[super insertObject:node
atArrangedObjectIndexPath:[self selectionIndexPath]];
[node release]; // and release
}
This works fine as a test - but the hard part is
replacing [self selectionIndexPath] with something
more meaningful - I need to use the same index path as
would be used by addChild: or add:...
> > I want exactly the same behaviour I would
> get
> > if I could use
> -outlineView:persistentObjectForItem:
> > and
> > -outlineView:itemForPersistentObject:.
>
> I'm less sure about this one, but I'm not sure why
> proxy objects are a
> problem here.
> Why can't you get the data you want from the proxy
> object?
The problem here is that the proxy object is of
private class _NSControllerTreeNode. I can use the
undocumented private method -observedObject to *get*
the data I want in
-outlineView:persistentObjectForItem:. The trouble is
that in -outlineView:itemForPersistentObject:, as I
understand it, I would then have to convert my
persistent object back to a proxy object, and there
seems no way of doing that.
Many thanks again,
Keith
--- Michael McCracken <email@hidden>
wrote:
> Not the definitive answers, but HTH:
>
> On 6/22/05, Keith Blount <email@hidden>
> wrote:
> > Hmm, having played with this I've made a miniscule
> > amount of headway, but it's been more headache
> than
> > headway mostly... If anyone has any ideas on how
> to
> > address the following issues when using
> > NSTreeController bound to an NSOutlineView, I
> would be
> > very grateful:
> >
> > 1) There is no addLeaf: method in
> NSTreeController, so
> > how can I set it up so that I have two buttons, an
> Add
> > Folder button that initiates child objects with
> their
> > leaf key path (an isLeaf BOOL in my model) set to
> NO,
> > and an Add Leaf button that initiates child
> objects
> > with the leaf key path set to YES?
>
> It sounds like you'd want to subclass
> nstreecontroller and provide
> those actions.
> In the methods you provide, create your entity and
> set the leaf
> keypath to the appropriate value.
>
> > 2) How do I save the state of the expanded items
> in my
> > outline view, given that the outline view's
> datasource
> > methods are rendered useless by NSTreeController
> > sending proxy objects to them? Obviously, I don't
> want
> > to save the state of the expanded items into my
> actual
> > file - I want exactly the same behaviour I would
> get
> > if I could use
> -outlineView:persistentObjectForItem:
> > and
> > -outlineView:itemForPersistentObject:.
>
> I'm less sure about this one, but I'm not sure why
> proxy objects are a
> problem here.
> Why can't you get the data you want from the proxy
> object?
>
> -mike
>
> > Many thanks,
> > Keith
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> > _______________________________________________
> > 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
> >
>
>
> --
> Michael McCracken
> UCSD CSE PhD Student
> San Diego Supercomputer Center
> http://www.cse.ucsd.edu/~mmccrack/
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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