I have a NSPopUpButton whose content values are bound to an NSArray of NSNumbers. The NSPopUpButton correctly displays the array of numbers in it's popup-menu. However, when I change the selected value, I receive a message:
HIToolbox: ignoring exception 'Unacceptable type of value for attribute: property = "tempo"; desired type = NSNumber; given type = NSCFString; value = 106.' that raised inside Carbon event dispatch
Obviously, this is occurring because the object to which the selected value is bound to is expecting an NSNumber, and the NSPopUpButton is giving it an NSString. Looking through other posts, I think what I need is a NSNumberFormatter.
However, I have tried using an NSNumberFormatter, both through Interface Builder, and programatically, but the result does not change. For reference, this is the code which I have used when attempting to set the formatter of the NSPopUpButton programatically:
tempoFormatter = [[NSNumberFormatter alloc] init];
[tempoFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[tempoFormatter setFormat:@"### bpm"];
[[tempoButton cell] setFormatter:tempoFormatter];
(tempoButton is an IBOutlet connected to the NSPopUpButton)
I am wondering if using an NSNumberFormatter is even what I need? If so, what I am doing wrong? I have read through the Data Formatting Programming Guide; it seems very straight-forward, but I feel like I am missing something.
Thanks in advance.