Master-detail interface with NSTreeController and NSOutlineView
Master-detail interface with NSTreeController and NSOutlineView
- Subject: Master-detail interface with NSTreeController and NSOutlineView
- From: Greg Hurrell <email@hidden>
- Date: Sat, 20 May 2006 22:14:21 +0200
Two questions about implementing a master-detail interface with
NSTreeController and NSOutlineView:
(1) Multiple top-level nodes
I've set up an NSTreeController that has it's content binding set to
a custom class containing an array of nodes. In my NSOutlineView the
custom class appears a single "root" node at the top-level. What I
actually want is for the contents of the root node to be shown at the
top level, that is, to have multiple top-level nodes.
The docs for NSTreeController (http://developer.apple.com/
documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/
NSTreeController.html) say that "The root content object can be a
single object, or an array of objects", so I imagine it should be
possible to do what I want. But I am not sure how I should set this
up in Interface Builder... How do you set up the contentObject
binding in this case? And do you have to change the "children key
path"? My first aborted attempt at passing an array instead of a
single object gave me runtime errors because the NSArray that I
supplied as contentObject didn't respond to the child key path; and
if I ditch the NSArray and make a custom class that does respond to
the children key path then I am back where I started (a single top-
level node).
(2) Master-detail interface details not working
I've tried to set up a master-detail interface similar to the one
described in the documentation (http://developer.apple.com/
documentation/Cocoa/Conceptual/CocoaBindings/Tasks/
masterdetail.html), but instead of NSArrayController/NSTableView I am
using the NSTreeController/NSOutlineView pair already described above.
For example, I have an NSTextField and I try to bind it to the
"selection" of the controller with model key path "displayName". This
same binding works fine for arrangedObjects in one of the
NSTableColumns in the NSOutlineView, but in the "detail" part of my
interface I don't see any value at all (or to be more precise, I see
the "no selection placeholder"... Why would I be seeing that when
there is definitely a row selected in the outline view?
The docs say:
Set the Bind to aspect to your array controller object. For
example, MediaAssetsController.
Set the Controller Key to selection (the currently selected object).
Set the Model Key Path to the property you wish displayed in that
view. For example, title.
And that is exactly what I've done but it doesn't work. Admittedly
that example is for NSTableView/NSArrayController, not NSOutlineView/
NSTreeController... but there seems to be a general lack of official
examples for NSTreeController, and the few unofficial samples
floating around on the net are generally tied to CoreData. I haven't
been able to find any master/detail examples for NSTreeController
with or without CoreData.
Experimenting trying to get this to work I also tried using
selectedObjects as the controller key as well as playing with some
array operators but that was just random experimentation and it
didn't work either. I just got an empty set of parentheses "()". What
do I need to do here? Or is NSTreeController not suitable for this
kind of thing?
Cheers,
Greg
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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