0
votes

I have a NSTableView bond to an NSArrayController. I want to be able to select a single row and get the values for the keys I have set in the tableview.

I have an IBOutlet for the table view and can get the selected row with:

NSInteger row = [tableView selectedRow];
NSLog(@"Selected Index = %ld", (long)row);

How do I ask the ArrayController to give me the value for key of this selected index?

1

1 Answers

0
votes

Create an outlet to the array controller and use

[arrayController selectedObjects];

Make sure that Selection Indexes of the table view is bound to Selection Indexes of the array controller.

If the result array is not empty the object is at index 0.
If multiple selection is enabled in the table view the array contains all selected objects in the table view order.