您好我正在尝试将 indexPath.row 中的字符串转换为货币格式的数组。下面是我的代码。但是当我在手机上运行时,lbl 中什么也没有出现——它是空白的。帮助表示赞赏!谢谢!!
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
NSString *groupingSeparator = [[NSLocale currentLocale] objectForKey:NSLocaleGroupingSeparator];
[formatter setGroupingSeparator:groupingSeparator];
[formatter setGroupingSize:3];
[formatter setAlwaysShowsDecimalSeparator:NO];
[formatter setMaximumFractionDigits:0]; //No decimal showings - to show 2 decimal digits enter 2 instead of 0
[formatter setUsesGroupingSeparator:YES];
totalnoformat = [[NSNumber alloc]init];
totalSCformat = [[NSString alloc]init];
totalnoformat = [total objectAtIndex:indexPath.row];
totalSCformat = [formatter stringFromNumber:totalnoformat];
cell.amountlbl.text = totalSCformat;