• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core data - binding related problem in NSNumberFormatter and NSDatePicker
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core data - binding related problem in NSNumberFormatter and NSDatePicker


  • Subject: Re: Core data - binding related problem in NSNumberFormatter and NSDatePicker
  • From: Andreas Grosam <email@hidden>
  • Date: Thu, 16 Dec 2010 14:31:56 +0100

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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Core data - binding related problem in NSNumberFormatter and NSDatePicker (From: Devarshi Kulshreshtha <email@hidden>)
 >Core data - binding related problem in NSNumberFormatter and NSDatePicker (From: Devarshi Kulshreshtha <email@hidden>)

  • Prev by Date: Re: Re: How to read a text file over a network
  • Next by Date: App Will Not Terminate After Uncaught Excpetion
  • Previous by thread: Core data - binding related problem in NSNumberFormatter and NSDatePicker
  • Next by thread: Re: Core data - binding related problem in NSNumberFormatter and NSDatePicker
  • Index(es):
    • Date
    • Thread