Reputation: 679
I need to retrieve a string from data from a selected row in a table to compare it to a string.
I call
NSArray *values = [self.tableArrayController selectedObjects];
To get the objects at the selected row. However, values only has a count of objects of 1, and everything seems to be one big, long string of all my values. I cannot search through the values because I won't always know what to search for. I need a specific value (of which they are organized by columns).
I was hoping that the array would be of a certain count and I could retrieve the string based on the index of the object for the string.
How should I get all the different values (organized by columns) for a selected row?
EDIT:
I populate a NSDictionary (withmore values than that, this is just an example). The string value is the column identifier. The object is the object I'm adding that I want to appear on the table. This part below already works as I want it to:
NSDictionary *dict =[NSDictionary dictionaryWithObjectsAndKeys:
object1, @"column",
object2, @"column2",
nil];
[self.tableArrayController addObject:dict];
Upvotes: 1
Views: 1267
Reputation: 89509
Another way to get data from your table is to look at the "NSTableView
" methods "selectedRow
" & "selectedColumn
".
With that information, you can get at the value you want directly via your array controller or you can use the NSTableViewDataSource method "tableView:objectValueForTableColumn:row:
" to pass you back the NSString value of whatever it is that you're trying to get at.
Upvotes: 2