Sorry, I know this is a pretty tricky question.
Life is easy when I want to make an NSTableview object on a screen with a fixed number of columns. I just bind the data to each column and just read / write this model (according to MVC).
But life becomes unkind when I need a table with a dynamic column number (I mean that the user is allowed to add / remove columns). By the time I used two different approaches: in the first and easier, but worse approach, I can make the table big enough so that the user cannot fill it! but I know that memory will never appreciate it!
In the second approach, I can create an NSTableColumn array and assign a numbered identifier for each column as follows:
Column NSTableColumn * [iColumn]; // NSInteger iColumn is defined by User
for( int i=0;i< iColumn;i++){
column[i] = [[NSTableColumn alloc] initWithIdentifier:[ NSString stringWithFormat:@"%i" ,i] ];
[column[i] setWidth:100];
[tableView addTableColumn:column[i]];
}
This works great, but there are some annoying limitations to this. For example, using "data binding" and using some drag & drop is much easier than processing a table with columns 1,2,3, ... programmatically.
I think that for this there should be an easier way to use UI Builder, rather than writing codes. Perhaps it is possible to bind data for the entire TableView, and not for each individual column (something like what is available in Visual Studio C ++ / Clr for the "dataTable" object. Or another method? Any answer would be kindly appreciated