NSPopupButton bound to NSArrayController not updating

Posted by BuzzB on Stack Overflow See other posts from Stack Overflow or by BuzzB
Published on 2013-11-09T03:38:48Z Indexed on 2013/11/09 15:54 UTC
Read the original article Hit count: 383

I've got an NSPopupButton bound to an NSArrayController. (Man, that was harder than I thought it would be!)

I have an NSArrayController bound to an NSMutableArray via the NSArrayController's "Controller Content" binding.

The "Content" and "Content Values" bindings of the NSPopupButton are bound to my NSArrayController, and "Selected Object" is bound to a member in my app delegate.

It is working as I expect. Except, when I add items to the NSMutableArray that my NSArrayController is bound to they don't appear in the popup. I kind of expected this to work automagically... with the NSArrayController observing the NSMutableArray and updating the NSPopupButton as necessary.

Clearly I am missing something.

[Update]

Ok, clearly I am adding items to my array in a way that the array controller can't see. I finally found this...

https://developer.apple.com/library/mac/documentation/cocoa/conceptual/CocoaBindings/Concepts/Troubleshooting.html

But I really don't understand what it means.

Does anyone know of a simple example of the proper way to dynamically added items to a bound NSMutableArray when the "adder" has no idea that there is a UI element bound to the array?

Any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa