我正在编写信用计算器,我希望在用户输入数字时使用(本地)千位分隔符格式化数字。
例如100000
应该成为100.000
(本地)。
在我的示例中如何做到这一点?
NSNumberFormatter *nf = [[[NSNumberFormatter alloc] init] autorelease];
[nf setNumberStyle: NSNumberFormatterDecimalStyle];
[nf setRoundingMode: NSNumberFormatterRoundHalfUp];
[nf setMaximumFractionDigits: 2];
double loanAmount = [[nf numberFromString: tbxLoanAmount.text] floatValue];
double intRate = [[nf numberFromString: annualInterestRate.text] floatValue];
double NRate = [[nf numberFromString: NInterestRate.text] floatValue];
double years = [[nf numberFromString: noOfYears.text] floatValue];
double residual = [[nf numberFromString: residualvalue.text] floatValue];
非常感谢!
D