0

I have a simple shoe size converter app and I want it to be so that if the answer requires no decimal places, there are none, just whole numbers. If the answer was 2, I don't want it to say 2.000000, it should say 2. If it requires one decimal place, it should show to one decimal place for example 12.8 instead of 12.80. How would I do this?

ViewController.m file

- (void)viewDidLoad
        {
            [super viewDidLoad];
            _countryNames = @[@"Europe", @"United Kingdom", @"Japan"];

            _sizeRates = @[ @11.5f, @.875f, @7.0f];
        }

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

                NSString *resultString = [[NSString alloc] initWithFormat: @"%3f USS = %3f %@", size, result, _countryNames[row]];
                _resultLabel.text = resultString;
            }
rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

2

use %.0f , %.1f etc to specify

ex. :

if(requires 1) 
{
// use %.1f
else
    {
    //use %.2f
    }
}

go on like that

Hope I helped.

Exothug
  • 339
  • 4
  • 18