NSTreeController, setObjectClass and selection
NSTreeController, setObjectClass and selection
- Subject: NSTreeController, setObjectClass and selection
- From: Michael McCracken <email@hidden>
- Date: Fri, 15 Jul 2005 16:59:52 -0700
Hi, I'd like to be able to tell an NSTreeController to change its
objectClass based on
what its selection was, so that I can use insertChild: and have it
insert the correct kind of object - the controller is displaying
multiple kinds of objects.
I was hoping to be able to do this by observing its selection and
setting its object class in a way appropriate to the selection
whenever the selection changed.
This doesn't work so well, because even though I have the controller
set to avoid empty selection, and the outline view set to not allow
empty selection, I still get one initial notification that claims
there is no selection, and I can't really do anything appropriate with
the marker.
I was going to show the code and results here, but as a further test,
I overrode insertChild: in my subclass of NSTreeController, and had it
set the objectClass instead.
Although I was able to confirm that it got set to the subclass of
NSManagedObject that I wanted (I had to change the selection once
before I got a meaningful selection class, as per above), it still
inserted a regular NSManagedObject - I can tell because I get selector
not recognized exceptions because I have a custom cell displaying an
icon.
Is there a way to get the TreeController to do what I want here, or am
I fighting a losing battle? I can create a new object and insert it in
the right relationship easily enough, but it'd save so much code if I
could use NSTreeController, and I'd get the new object selected for
free as well, which doesn't happen if I just insert it right into the
MOC.
Thanks for any help,
-mike
--
Michael McCracken
UCSD CSE PhD Candidate
research: http://www.cse.ucsd.edu/~mmccrack/
misc: http://michael-mccracken.net/blog/
_______________________________________________
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