I’m struggling with this issue, and I couldn’t find any resource for it :
I have an NSNumber that I want to display in an UITextField, so the user can edit it.
So I need to convert this NSNumber to an NSString, like this :
float value -> desired string value
1.0000000... -> 1
10.000000... -> 10
1.1230000... -> 1.123 or 1,123 depending on the locale
1000000.0... -> 1000000
I’ve tried to use NSNumberFormatter, but then I get spaces or comas for big numbers :
1000000.0... -> 1,000,000 or 1 000 000 depending on the locale
I also tried
[NSString stringWithFormat:@"%g", val]
But then for big numbers I have a scientific expression :
1000000.0 -> 1e+06
Did somebody have a successful experience with this ?
NSNumberFormatterhas such method as :I think, you can return to variant where you has:
and set additional parameter using that function:
Or moreover try this method: