0

I am learning about Cocoa binding and as part of that working on a simple testbed where I populate a NSPopUpButton with some options via a NSArrayController. It all shows up fine and I can change the button selection. I then tried to bind the title of NSWindow to display the string of the data the NSPopUpButton is bound to. It works as far as startup goes..showing the first item in the popup... but no matter the change in the popup selection the title doesn't change. This all works fine if I swap NSPopUpButton with NSTableView. Am I right in thinking that NSPopUpButton does not track user selection, and that if I want to track that I need to set a property in my model to track that?

Thanks!

greekgoddj
  • 117
  • 1
  • 6
  • 1
    Be more specific about the bindings you have set up. Specify which binding(s) you have connected (e.g. "Title", "Value", "Content", etc.), to what object/controller, with what controller key (if any), and what model key path. I would expect it to work to set the pop-up's Selected Index to the array controller's `selectionIndex` and then bind the window's Title to the array controller's `selection` with an appropriate model key path (which depends on what sort of objects the array contains). – Ken Thomases Sep 08 '14 at 01:25
  • 1
    A great explanation [here](http://stackoverflow.com/questions/14888175/binding-a-nsarraycontroller-to-a-nspopupbutton-nstextfield) – Cory Sep 08 '14 at 17:23
  • Hi Ken, you are right, in your expectation... that is what I was missing (binding the pop-up's SelectedIndex to the array controller's selectionIndex). I was going round and round in circles, and then when I saw the following link, I thought I started doubting if it was possible. [link](http://blog.chrisblunt.com/cocoa-bindings-and-nspopupbutton/) It works as expected now, thanks. Also thanks Cory for that link, I could have sworn I went through all existing posts. Thanks to you both! :o) – greekgoddj Sep 08 '14 at 19:22

0 Answers0