Skip navigation.
 
mlRe: NSComboBox bug?
FROM : matt neuburg
DATE : Thu Oct 31 21:04:00 2002

On 10/31/02 at roughly 1:50 PM, thus spake Nicholas Riley <<email_removed>>:

>On Thu, Oct 31, 2002 at 11:29:52AM -0800, matt neuburg wrote:
>> >Nope, it's a bug that's been there since 10.0.  You can't have a combo
>> >box with a formatter if you want the combo box to work.

>>
>> Piffle. Formatters work perfectly well with comboboxes; I use them
>> all the time. A combination of a formatter and a datasource is a
>> very powerful way to run a combobox.

>
>It would be lovely if it were documented somewhere.


What's not documented?

>> The problem with the above example is that an NSNumberFormatter
>> expects numeric values, but "0", "1" and so forth aren't numbers;
>> they're strings. m.

>
>This makes it impossible to edit the combo box list from IB - again,
>this is not documented.


Here's what the NSNumberFormatter doc says - this is the first sentence - "Instances of NSNumberFormatter format the textual representation of cells that contain NSDecimalNumbers and convert textual representations of numeric values into NSDecimalNumbers."

Here's what the Data Formatting topic says: "The value of a cell (NSCell) is represented by an object, which in this case would typically be a number object. When this value needs to be displayed or edited, the cell passes its object to the NSNumberFormatter instance, which returns the formatted string. When the user enters a string, or when a string is programmatically written in a cell (using setStringValue), the cell obtains the equivalent number object from the NSNumberFormatter."

Short of banging me over the head with a big stick and yelling in my ear, I don't see how the docs could be telling me any more clearly that an NSNumberFormatter takes and returns a number object value.

Now, if you don't want this behavior, don't use an NSNumberFormatter. There's no problem whatever with having a formatter that takes a string object value; you'll just have to write it yourself, which is very easy to do. Then, the string values that you can enter in IB will work.

m.

matt neuburg, phd = <email_removed>, http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlNSComboBox bug? Stéphane Sudre Oct 31, 17:56
mlRe: NSComboBox bug? Nicholas Riley Oct 31, 19:01
mlNSComboBox bug? matt neuburg Oct 31, 20:29
mlRe: NSComboBox bug? Nicholas Riley Oct 31, 20:50
mlRe: NSComboBox bug? matt neuburg Oct 31, 21:04
mlRe: NSComboBox bug? Nicholas Riley Oct 31, 21:31
mlNSComboBox bug? matt neuburg Nov 1, 13:51