views:

253

answers:

2

how can i get value of selected row in NSTableView?

+1  A: 

By using selectedRow, see here:

"The index of the last row selected or added to the selection, or –1 if no row is selected."

You may also be interested in:

–selectedRowEnumerator (deprecated)

–numberOfSelectedRows

–selectedRowIndexes "returns an index set containing the indexes of the selected rows"

Ramashalanka
+6  A: 

Cocoa follows the Model-View-Controller design pattern, so your reasoning as well as your own designs should as well.

You don't get any values from the table because you already have them in your model. Your controller (usually the data source) asks the table for its selected row index(es), then asks your model for the objects matching those indexes, then does whatever it needs to do.

Joshua Nozzi