0

I have an NSButtonCell as data cell in one of my NSTableView's columns. The table view is cell-based and has two columns ; one with the button cell, one with a text field cell.

The button cell's respective column's target and argument are bound to my app delegate (as the target) and to the selectedObjects array of an NSArrayController (as the argument). Basically the same as what's outlined in one of Apple's Technical Q&As.

When I open the app, the table view is automatically populated. Everything works as expected. If I click a button my action method gets called just fine, and this method receives the selectedObjects as a parameter.

It's just not the functionality I want ; I'd like to get the object that is represented by the row of the clicked NSButtonCell instead of the currently selected objects (in my case this is an NSString as my NSArrayController is populated with strings).

Is it possible to get this particular object, only through bindings? Or should I, instead, set the selector of the NSButtonCell (the data cell) without bindings? And then get the object by using NSTableView's -clickedRow method?

  • 1
    It might work to bind the argument to `arrangedObjects`. In theory, when you do that, each row would be bound to the individual object, not the array of objects, but the theory may be wrong. – Ken Thomases Sep 21 '17 at 19:48
  • Yeah I thought that too, didn't work. It works for the `NSTextFieldCell` though. Rather confusing. – Bruno Vandekerkhove Sep 21 '17 at 19:49
  • If `-clickedRow` returns the correct value the way it's set up now, that might work. (I don't use array controllers for table views very much.) – Wevah Sep 22 '17 at 17:10

0 Answers0