• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Binding an OutlineView and/or its TableColumn to a TreeController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding an OutlineView and/or its TableColumn to a TreeController


  • Subject: Binding an OutlineView and/or its TableColumn to a TreeController
  • From: Stuart Malin <email@hidden>
  • Date: Tue, 24 Feb 2009 19:41:08 -1000

I have a data model that is bound to a TreeController. The TreeController manages an OutlineView.

When I first implemented this, I bound the TableColumn backing the OutlineView to the TreeController (the TableColumn's Value property to the TreeController's arrangedObjects with a Model Key Path for the property I want displayed). This worked fine -- even though I did not bind the OutlineView in any way to the Tree Controller. In some sample code I have been looking at, the Content property and the Selected Index Paths property of the OutlineView are bound to the TreeController (arrangedObjects and selectedIndexPaths, respectivel); this is in addition to the TableColumn's bindings. I am not sure what, if any, functionality I am losing by *not* binding the OutlineView as well. (It seems to work just fine, expanding and collapsing tree nodes).

Question 1: Is it necessary to bind both the OutlineView and the TableColumn?


I can also make this work in the converse: binding the OutLineView's Content property and *not* binding the TableColum's Value. Well, almost works as no data is actually displayed. But that is overcome because (for other reasons) I use a custom cell for the TableColumn. I've got a controller that is the delegate for the OutlineView, and it implements:


- (void)outlineView:(NSOutlineView *)outlineView
    willDisplayCell:(NSCell*)cell
     forTableColumn:(NSTableColumn *)tableColumn
               item:(id)item

When this delegate method is invoked, I call -setStringValue on the cell (with data gotten from the represented item), thereby setting its value, which is properly displayed.

Question 2: is this a valid approach (that is, bind only the OutlineView's Content property and supply the text via the delegate method)? I ask because while this does work, I don't know what gotchas may be lurking that I have not yet stumbled upon.



_______________________________________________

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:
This email sent to email@hidden


  • Prev by Date: Re: Stop edit session with a NSTextField
  • Next by Date: Re: plug-in
  • Previous by thread: Re: plug-in
  • Next by thread: {Solved]: Adding text to NSImage using lockFocus/unlockFocus not working
  • Index(es):
    • Date
    • Thread