FROM : Scott Stevenson
DATE : Sat Apr 30 01:34:33 2005
On Apr 29, 2005, at 3:31 PM, Josh Anon wrote:
> I didn't see this in the archives, but it feels like it should be an
> obvious question. I have a custom view that displays a collection of
> objects. I'd like to do something like NSTableView/NSTableColumn
> where I can just say "bind the text to an array controller's
> arrangedObjects.text and the label to arrangedObjects.label."
> However, I don't see how the custom view will be able to get
> information from the array controller (selection, # objects, etc.)
> without specifying the array controller as an outlet. I guess you
> could have a selection + objects array in the view that you bind the
> array controller's selection and arrangedObjects items to, but that
> seems more complicated than it should be. Is there a clean way to set
> it up like NSTableView?
Hello Josh Anon,
You register for KVO notifications on the array controller inside bind:
and update the view's contents when observeValueForKeyPath: is called.
That method passes in the bound array controller, so you can just query
it directly for its new contents, using the key path specified during
the initial bind.
- Scott
--
http://treehouseideas.com/
http://theocacao.com/ [blog]
DATE : Sat Apr 30 01:34:33 2005
On Apr 29, 2005, at 3:31 PM, Josh Anon wrote:
> I didn't see this in the archives, but it feels like it should be an
> obvious question. I have a custom view that displays a collection of
> objects. I'd like to do something like NSTableView/NSTableColumn
> where I can just say "bind the text to an array controller's
> arrangedObjects.text and the label to arrangedObjects.label."
> However, I don't see how the custom view will be able to get
> information from the array controller (selection, # objects, etc.)
> without specifying the array controller as an outlet. I guess you
> could have a selection + objects array in the view that you bind the
> array controller's selection and arrangedObjects items to, but that
> seems more complicated than it should be. Is there a clean way to set
> it up like NSTableView?
Hello Josh Anon,
You register for KVO notifications on the array controller inside bind:
and update the view's contents when observeValueForKeyPath: is called.
That method passes in the bound array controller, so you can just query
it directly for its new contents, using the key path specified during
the initial bind.
- Scott
--
http://treehouseideas.com/
http://theocacao.com/ [blog]
| Related mails | Author | Date |
|---|---|---|
| Josh Anon | Apr 30, 00:31 | |
| Scott Stevenson | Apr 30, 01:34 | |
| mmalcolm crawford | Apr 30, 01:48 | |
| Josh Anon | Apr 30, 02:24 |






Cocoa mail archive

