Re: API to convert string to number?
Re: API to convert string to number?
- Subject: Re: API to convert string to number?
- From: "E. Wing" <email@hidden>
- Date: Tue, 27 Feb 2007 16:08:09 -0800
So NSScanner seems to be the closest to what I need. But it fails to
respond to the NSThousandsSeparator. Looking over the documentation,
there is only mention of the decimal separator. Is it possible to get
it to handle the other separators?
Basically, what I want is when the user types 1,000.50 (in en-US), I
want the value 1000.5. But I actually get 1.0 in this case.
Here is the code I'm using:
float converted_value;
NSScanner* the_scanner = [NSScanner localizedScannerWithString:user_string];
BOOL did_find_number = [the_scanner scanFloat:&converted_value];
Thanks,
Eric
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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