newbie question on NSTableView (obj-c cocoa)

benixau

Registered
how do i read the contents of a cell in an NSTableView called tableView.

I looked at apples examples and they are all single column versions. i have three columns which have identifiers.

please help. thanx.
 
Implement a class with three instance variables, an init method, and accessor methods for the three variables.

The names of the three variables will match the names of your tableview's three column identifiers.

Your objectValueForTableColumn method will look something like this:<font size = "+1"><pre>- (id)tableView:(NSTableView *)aTableView<br> objectValueForTableColumn:(NSTableColumn *)aTableColumn<br> row:(int)rowIndex<br>{<br> //use a string to select the current identifier<br> NSString *identifier = [aTableColumn identifier];<br><br> //For tableRowData, subistitute whatever class stores your row data<br> //For tableViewDataArray, substitute the name of your array of tableRowData objects<br> tableRowData *rowData = [tableViewDataArray objectAtIndex:rowIndex];<br><br> //You can now display cell objects this way:<br> [rowData takeValue:anObject forKey:identifier];<br>}
</pre></font>
Your setObjectValue method will return [rowData valueForKey:identifier];
 
Back
Top