0
我正在开发我的第一个iPhone应用程序,并且希望能够使用设备的货币设置格式化货币。使用设备的货币设置格式化输出
目前我有这样的:
- (IBAction)calculate {
float lp = ([leftPrice.text floatValue]);
float rp = ([rightPrice.text floatValue]);
float lw = ([leftWeight.text floatValue]);
float rw = ([rightWeight.text floatValue]);
float lppkg = lp/lw;
float rppkg = rp/rw;
if (lp > 0 && lw > 0) {
leftPricePerKg.text = [[NSString alloc] initWithFormat:@"$%.2f", lppkg];
}
if (rp > 0 && rw > 0) {
rightPricePerKg.text = [[NSString alloc] initWithFormat:@"$%.2f", rppkg];
}
}
感谢。我尝试了以下方法,但无法使其正常工作。我显然缺少一些东西:currency.text = [NSString currencySymbol]; – 2011-06-06 08:55:28