NSPopUpButtonCell - How To Get The Changed Value

  • I have a tableview that has two columns. The second column has an NSPopUpButtonCell. The tableview content is supplied via an array controller of dictionaries. The first column shows the "title" key's value and the second column (the NSPopUpButtonCell) shows and array of choices in the dictionaries "options" key.  The array is a property of the view controller. All of the bindings are functioning correctly but I can't seem to make KVO work since it's an array in a dictionary inside an array. Ideally I would observe the change and then update a separate object with the new value. Each of the NSPopUpButtonCells in the tableview has it's own distinct set of options which is why I have put them as a property in the dictionary.

    Since bindings seem impossible with this approach, I set the NSPopUpButtonCell's action to a method in my view controller with the thought of grabbing the new value and then updating my models property manually. However the action seems to be sent before bindings has actually updated anything so I still get the old value that is the value selected before I changed the selection in the menu. Anyway, I'm at a dead end and would really appreciate any help and critique.

  • On 2013 Jun 08, at 18:28, Chris Tracewell <chris...> wrote:

    > I can't seem to make KVO work since it's an array in a dictionary inside an array.

    In the area of tables and bindings, there are typically a half dozen design patterns which should work but don't, and one that works.  Binding to an array controller is generally the pattern that works.

    I think you need to replace that dictionary with a class that has properties which you can bind to.  In the table column containing your popup cell, bind the Selected Object to the array controller with Controller Key = arrangedObjects, and Model Key Path = thatProperty.
previous month june 2013 next month
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today