• 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: Can't get the formatted number of NSTextfield
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't get the formatted number of NSTextfield


  • Subject: Re: Can't get the formatted number of NSTextfield
  • From: Fritz Anderson <email@hidden>
  • Date: Mon, 17 May 2010 15:51:41 -0500

On 17 May 2010, at 7:15 AM, Gustavo Pizano wrote:

>
> I need to get the value of a textfiled which has a NSNumberFormatter with currency style.
>
> Now, Im doing:
>
> 			double d = [amountPayedTF doubleValue];
> 		NSDecimalNumber * dm = (NSDecimalNumber *)[NSDecimalNumber numberWithDouble:d];
> 		..
>
> so then I can compare the decimals number with the entitie's attributes.
>
> BUT, on d, Im always getting just the thousand digit (the first one) when inputing for example 2664, when formatted it becomes 2.664.00 €, so Im geting only 2, if I put 264 --> 264.00 € I get the 264, and if I put 264.15 -> 264.15 € I get 264.15 in d...

My experiments show that NSNumberFormatter does not tolerate grouping separators in input text. Or at least I wasn't able to force it.

On another subject, I'd recommend that you never pass currency amounts through a double. You have a formatter attached to your field. Set it to always return an NSDecimalNumber (it's in the Mac OS X 10.4+ Custom inspector), and use the objectValue method of the text field to retrieve the decimal number directly.

	— F

_______________________________________________

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

  • Follow-Ups:
    • Re: Can't get the formatted number of NSTextfield
      • From: Gustavo Pizano <email@hidden>
References: 
 >Can't get the formatted number of NSTextfield (From: Gustavo Pizano <email@hidden>)

  • Prev by Date: Re: Style Advice for using NSEnumerator
  • Next by Date: Re: Can't get the formatted number of NSTextfield
  • Previous by thread: Can't get the formatted number of NSTextfield
  • Next by thread: Re: Can't get the formatted number of NSTextfield
  • Index(es):
    • Date
    • Thread