• 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: NSNumberFormatter and localized format problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumberFormatter and localized format problem


  • Subject: Re: NSNumberFormatter and localized format problem
  • From: Eric Morand <email@hidden>
  • Date: Thu, 27 Apr 2006 09:36:36 +0200

I've typed exactly the lines you gave to me on my awakeFromNib :

- (void)awakeFromNib
{
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];

[numberFormatter setFormatterBehavior: NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];

[testTF setFormatter:numberFormatter];
}


(testF being the text field)

Now, each time I type a number (I tried typing "1") in the field (and the fiel lose the first responder status), I have a sheet that is displayed with a format error message (in french is says "Erreur de formatage" that should translate in "Formatting error").




Eric.


Le 27 avr. 06 à 07:34, Tony S. Wu a écrit :

NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];

[numberFormatter setFormatterBehavior: NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];

should work.
also, a got-cha in NSNumberFormatterCurrencyStyle is that when the control is set to display with currency style, it has to have the input data WITH the currency symbol as well.
meaning (in US currency) when a user inputs "24.00" it is considered inappropriate.
he/she has to input "$24.00".
i encountered this problem with my table column, if anyone finds anyway around this or my information incorrect, please do let me know.


Tony S. Wu
email@hidden



On Apr 26, 2006, at 2:05 PM, Eric Morand wrote:


Le 26 avr. 06 à 17:05, Nick Zitzmann a écrit :


On Apr 26, 2006, at 7:42 AM, Eric Morand wrote:

Am I doing something wrong ? How am I suppposed to display correctly formatted amount in my text field ?

-setNumberStyle: only works if you're using an NSNumberFormatter that uses the Tiger behavior. Did you try setting the behavior of the formatter first?


Yes, I've just added it doesn't format anything. If I type 1500 in the field, it remains 1500 instead of 1 500,00 €. I just don't get it.



Nick Zitzmann <http://www.chronosnet.com/>





_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: NSNumberFormatter and localized format problem
      • From: "Tony S. Wu" <email@hidden>
References: 
 >NSNumberFormatter and localized format problem (From: Eric Morand <email@hidden>)
 >Re: NSNumberFormatter and localized format problem (From: Nick Zitzmann <email@hidden>)
 >Re: NSNumberFormatter and localized format problem (From: Eric Morand <email@hidden>)
 >Re: NSNumberFormatter and localized format problem (From: "Tony S. Wu" <email@hidden>)

  • Prev by Date: Altering range for font changes in NSTextView?
  • Next by Date: How to retrieve currencies list
  • Previous by thread: Re: NSNumberFormatter and localized format problem
  • Next by thread: Re: NSNumberFormatter and localized format problem
  • Index(es):
    • Date
    • Thread