• 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
iOS From 1,99 To 1.99
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iOS From 1,99 To 1.99


  • Subject: iOS From 1,99 To 1.99
  • From: Sandro Noël <email@hidden>
  • Date: Thu, 29 Dec 2011 16:39:05 -0500

Greetings!

This is simple I'm sure and I'm just missing the proper class to do it.
I need to convert a string representation from Canadian local to US Local.
1,99 to 1.99

The model is a float called quantity.

From that model I pick up the value and display a localized representation of that float value into a UITextField (1,99)
to allow user to edit the value, when the user is done updating the value I need to pick up the string from the text field and update the model.

self.model.quantity = [self.numberTextView.text floatValue];

Only return 1.00 which is not correct.

NSLocale *locale = [[NSLocale alloc]initWithLocaleIdentifier:@"en_US"];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc]init];
[formatter setLocale:locale];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *number = [formatter numberFromString:self.numberTextView.text];
NSString *numberString = [[NSString stringWithFormat:@"%.2f", [number floatValue] ];
NSLog(@"%@",numberString);

Returns 0.00, even worst!!

What am I missing ?

Sandro._______________________________________________

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: iOS From 1,99 To 1.99
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: RaiseMan Exception
  • Next by Date: Code error in Your First Mac App tutorial..
  • Previous by thread: Re: RaiseMan Exception
  • Next by thread: Re: iOS From 1,99 To 1.99
  • Index(es):
    • Date
    • Thread