Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make a NSTableView with dynamic number of columns and binding in Cocoa /Xcode?
    primarykey
    data
    text
    <p>Sorry, I know this is a bit complicated question .</p> <p>Life is easy when I want to make a NSTableview object on screen with fixed number of columns. I just make a data binding to each column and simply read/write to that model (according to MVC).</p> <p>But life gets unkind when I need a table with dynamic column number ( I mean user is allowed to add/ remove columns) . By the time I have used 2 different approaches: In first and easier , but worst approach I can make a table big enough , such that user can never fill it up !. but I know the memory would never appreciate that !!</p> <p>In second approach , I can make an array of NSTableColumn and assign a numbered identifier to each column like this:</p> <blockquote> <p>NSTableColumn * column[iColumn]; //NSInteger iColumn is defined by user</p> <pre><code> for( int i=0;i&lt; iColumn;i++){ column[i] = [[NSTableColumn alloc] initWithIdentifier:[ NSString stringWithFormat:@"%i" ,i] ]; [column[i] setWidth:100]; [tableView addTableColumn:column[i]]; } </code></pre> </blockquote> <p>This works fine, but there are some annoying limitations to that .for example using "Data binding " and using some drag&amp;drops is so much easier than handling a table with columns numbered as 1,2,3,.... programatically .</p> <p>I think to myself there must be some easier way to use UI Builder for this purpose rather than writing codes.Perhaps it may be possible to bind data for whole TableView rather than for each individual column ( something like what is available in Visual Studio C++/Clr for "dataTable" object. Or another method ? Any answer would be kindly appreciated</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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