Reputation: 18149
My NSTableView lists some strings. I managed to fill the list with strings and react whenever the user selects a new option. However, I am having trouble getting the string that is being chosen. Any ideas?
Upvotes: 0
Views: 382
Reputation: 7272
I would suggest you take a look at the NSTableViewDelegate protocol. The table view notifies its delegate when the selection chages by calling tableViewSelectionDidChange:
. You can implement that method, ask the table view which row(s) are selected and pull the relevant data from your datasource array.
Upvotes: 1
Reputation: 119242
Assuming your strings are being held in an array (dataSourceArray
) which you are using as the table's (tableView
) data source:
NSString *selectedStringValue = [dataSourceArray objectAtIndex:[tableView selectedRow]];
If you are doing anything more complicated than that you will have to add more detail to your question, perhaps how you are deriving the values in the first place?
Upvotes: 2