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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to