tags:

views:

24

answers:

1

hi,

i want to do padding of characters by using nsnumberformatter. For Example. if string's value is 1 then it should get converted to 1.0.0. and if string value is 1.2 then it should get converted to 1.2.0

please help if any one know this.

Thanks in advance

A: 

Do you need to use NSNumberFormatter for this ? If you convert the string to a float value:

NSString *string = @"1.2";
float num = [string floatValue];

You can use the NSString -stringWithFormat: method to print the number as you see fit:

NSString *newString = [NSString stringWithFormat: @"%.1f.0", num];

newString would now be "1.2.0"

RichB