yvesf
yvesf

Reputation: 31

NSNumberFormatter to add currency symbol

I'm trying to use a NSNumberFormatter to display a money amount in an NSTextField.

I would like to have the application display the dollar sign, but when the user replaces the existing value I would just type 12.34 instead of 12.34$, and let the application add the dollar sign. I get a popup that says : The value "12.34" is invalid. Please provide a valid value". When I add the $sign it's working fine.

I don't have a piece of code to provide since the NSNumberFormatter is part of my XIB (and thus defined thru Xcode's User Interface). I'm using the 10.4 behaviour with currency style. Tried both 10.4 default behaviour and 10.4 custom behaviour. I tried lots of different formats, the consistent point is that as soon as there is a currency sign in the format and the user doesn't provide the currency sign, I get the error popup.

Thanks !

Yves

Upvotes: 1

Views: 337

Answers (1)

stevesliva
stevesliva

Reputation: 5655

Try checking Lenient in the attributes inspector for the Number Formatter. Programmatically, that corresponds to setLenient:YES

Upvotes: 1

Related Questions