これは、それを行う方法を示す単なる指標例です。このコードを調べて、状況に合わせて再適応する必要があります。それを試してみてください:
@autoreleasepool
{
// Here I create the formatter and I set the format. You do this faster with setFormat: .
NSNumberFormatter* formatter=[[NSNumberFormatter alloc]init];
formatter.numberStyle= NSNumberFormatterCurrencyStyle;
formatter.maximumIntegerDigits=6;
formatter.maximumFractionDigits=2;
formatter.currencySymbol= @"$";
formatter.currencyDecimalSeparator= @".";
formatter.currencyGroupingSeparator= @",";
formatter.positivePrefix=@"";
NSArray* numbers= @[ @1 ,@2 ,@3 ,@4, @5, @6, @7, @8 ];
// These are the inserted numbers, you should change the code in a way that
// every number is taken in input from the text field.
float number=0.0f;
for(NSUInteger i=0;i<8;i++)
{
// It just simulates what happens if the user types the numbers in the array.
number= [numbers[i] floatValue] * 1.0e-2 + number*10;
NSLog(@"%@",[formatter stringFromNumber: @(number)]);
}
}