Skip navigation.
 
mlRe: Bindings, arrangedObjects, and a NSTableView-like view
FROM : Daniel Jalkut
DATE : Thu Apr 21 18:19:18 2005

Hi Rob - I'm just a beginner with bindings, too, but maybe my 
thoughts on your situation will help us come to a  better 
understanding of what should happen, or will spur on more experienced 
folks to chime in.

On Apr 21, 2005, at 5:12 AM, Rob Giseburt wrote:
> Basically, I want to make something like Safari's Downloads window 
> or Mail's Activity Viewer, where it's a vertically stacked view of 
> subviews.


An array of stacked objects with interior detail is conceptually 
identical to a tableview, except that all of your columns are 
"squished" into a single view.  So for instance, where "name," "age," 
and "address" might have been columns in a typical table, here you 
are putting them all in your view.  Where before they could have been 
independently managed by NSTableColumn bindings, here something else 
will have to manage them.

> I would like to be able to bind items (controls, labels, etc) of 
> the subviews to an
> NSArrayController, but I can't figure out how to to the magic that 
> NSTableColumn seems to do with the 'arrangedObjects' key.


I think the "magic" is just that when an NSTableColumn binds to 
arrangedObjects, it knows to use that object combined with the 
designated keypath as the "ordered values" for that column.

So looking at things from a data source perspective, binding a column 
"MyColumn" to the arrangedObjects object with a key path of "name" 
means something along the lines of:

When I get my data source callback, if the column idenitifer is 
"MyColumn" then return the object [arrangedObjects valueForKey:@"name"];

> For example, when I place a subview in the view, how do I let it 
> know which arrangedObjects index to look at? How can I even tell 
> which controls of the subview are bound to the NSArrayController? 
> Or, do I tell the NSArrayController about the subview?


The arrangedObjects binding is only useful if you are in a position 
to know something about how to dole out the contents.  I'm thinking 
the solution to your problem is going to be not binding the 
individual controls of each view, but binding the manager of these 
views to the arrangedObjects.

So if you've got view1, view2, and view3 stacked in a row, you'll 
need some kind of "Column Manager" object whose "content" (or 
whatever you want to call it) is bound to arrangedObjects.  When 
column manager notices a change in content, it will go through the 
list of views and set their values in order from the new value of 
arrangedObjects.

As I said, this is my naive take on the problem, and hopefully 
somebody more experienced will over more sage advice.  My biggest 
doubt about this analysis is whether there isn't a better way to 
"automatically bind" the independent views to the arrangedObjects, 
without the explicit re-assignment by the "Column Manager."

All of this really highlights the value that would come from making 
example code available for a reasonably complicated view that exposes 
its own bindings.  I haven't found many examples along these lines, yet.

Daniel

Related mailsAuthorDate
mlBindings, arrangedObjects, and a NSTableView-like view Rob Giseburt Apr 21, 00:47
mlRe: Bindings, arrangedObjects, and a NSTableView-like view Rob Giseburt Apr 21, 14:12
mlRe: Bindings, arrangedObjects, and a NSTableView-like view Daniel Jalkut Apr 21, 18:19