PDA

View Full Version : NSPopupButton Bindings




knightlie
Jun 4, 2012, 11:32 AM
I always have trouble getting a grasp of NSPopupButton bindings. Here's my scenario:

I'm setting the currencyCode property of a Core Data object to a three-letter currency code. I use an NSPopupButton to do this with an array of codes bound to Content, but I want the popup menu to show the currency names. Based on the answer here (http://stackoverflow.com/questions/679207/binding-an-nspopupbutton-to-an-nsdictionarycontroller) I've tried using an NSDictionary where currencyCode=currencyName, but I get an error along the lines of "Binding contentObjects of object <NSPopUpButton: 0x20043cda0> ignored: Key path (currently bound as arrangedObjects.key) needs to have the content key path (arrangedObjects.value) as prefix".

I tried using an intermediate CurrencyCode class holding a code and a name, but the three-letter code in the Core Data entity then has nothing to bind to.

I feel like I'm missing an obvious answer to this, but I always hit a snag when binding popup buttons.