Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementing NSOutlineView/NSTableView with different cells (and data types) per row
    text
    copied!<p>I'm wondering how one would implement an outline view like the one Xcode 3 is using for the build configuration:</p> <p><a href="http://img812.imageshack.us/img812/9467/xcodeoutlineview.png">alt text http://img812.imageshack.us/img812/9467/xcodeoutlineview.png</a></p> <p>When using an NSOutlineView/NSTableView with bindings and an NSTreeController/NSArrayController, the <strong>view's columns get bindings assigned to</strong>, not the individual cells, for obvious reasons. If every row in a column uses the same cell, then it's a piece of cake. However if <strong>every row (potentially) uses its own cell type</strong> (and with that potentially its very own collection of bindings), then things get funky.</p> <p>Looking at the screenshot one can clearly see that the textfield cell needs just a single binding for "value". While the popup button cell needs at least one for "<strong>content</strong>", one for "<strong>contentValues</strong>" and last but not least one binding for "<strong>selectedIndex</strong> / <strong>selectedObject</strong> / <strong>selectedValue</strong>". And the checkbox cell needs a binding for "<strong>value</strong>" and (probably) one for "<strong>title</strong>".</p> <p>How would one accomplish this with as clean (and little) code as possible?<br> (<em>Or as one might ask:</em> <strong>How would Apple have done it</strong>?)</p> <p>… </p> <p>Here's what I've tried myself so far:<br> I provide the appropriate (copied) cells via <strong>[outlineView:dataCellForTableColumn:item:]</strong> and bind them to the individual data models (from [item representedObject]). I know the exact amount of data (&lt; 500 rows) being displayed in the outline view, so having one cell per row shouldn't be too much of a memory issue, no? I got the <strong>data to get displayed properly</strong> via bindings (yay!) however I'm unable to change any of their values. O_o Apparently the value change simply never gets thru to the data model. Is there more to it than a simple <strong>[checkboxCell bind:@"value" toObject:rowModel withKeyPath:@"value" options:nil]</strong>? (as this seems <strong>sufficient</strong> for <strong>getting</strong> values, but not for <strong>setting</strong> them accordingly.)</p> <p>I couldn't find any information on this topic. Lots of info and hints for using custom cells per column, but none for using them on a "per row" basis. :(<br> This would make some great stuff for a Cocoa tutorial, wouldn't it? ;)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload