On Dec 16, 2010, at 11:38 AM, Devarshi Kulshreshtha wrote:

> Hi Pat,
> 
> Regarding:
> 
> For #1, you have an non-ascii character at the front of the number formatter
>> (in IB).
Guess, ¤ (\u00A4) is the "localized currency symbol" defined in the 
"International Components for Unicode" Library (ICU) 
<http://unicode.org/reports/tr35/tr35-6.html#Number_Format_Patterns>  - and a 
valid character. But admittedly, it looks strange. ;)

> 
> It is now working correctly when I am entering the price with $ symbol
> prefixed, eg. $123,00 :)
According your project, you use a *localized* currency number formatter (in IB 
there is a check-box where you can set/unset this). The currency symbol must 
then match those defined in your current locale. That is, "$123.00" works only 
if your currency symbol for your current locale is "$" as well. You probably 
don't want this behavior, since on any other computer, the currency symbol can 
be different - for example on my Mac I would have to type "€" for the symbol.


> 
> I think that this is not user intuitive, user may not always know that he/
> she has to prefix dollar symbol. I think it would have been good if:
> 
> 1. I can somehow change the alert message which now says - "Formatting
> Error" to "You should prefix dollar symbol".
> 
> 2. Numberformatter can automatically prefix the '$' symbol to the entered
> decimal number.
> 
> Do you know any way to implement these?
Since I don't know what IB is doing exactly, do it programmatically. Here is 
the code which may solve your issue: 

    NSNumberFormatter* priceFormatter = [[NSNumberFormatter alloc] init];
    [priceFormatter setFormat:@"$#,##0.00;$0;-$#,##0.00"];
    [priceField setFormatter: priceFormatter];
    [priceFormatter release];

Note that, here in this example, the currency symbol is fixed and equals to 
"$". 
It is not required to explicitly type the currency symbol, eg.: "123" -> 
$123.00 Parsing works also if you type it in correctly say, "$123" -> "$123.00".



Regards

Andreas_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to