iOS From 1,99 To 1.99
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