您好我試圖從貨幣格式的數組中的indexPath.row轉換字符串。以下是我的代碼。但是當我在手機上運行時,lbl中沒有顯示 - 它是空白的。幫助表示讚賞!謝謝!!從一個數組中的indexpath.row格式化NSString到貨幣格式
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;
你能給我們提供關於什麼是「全部」的更多信息嗎? – LuisEspinoza
Total是從中我需要一個字符串格式的數組 –
而且,你確定這些元素是來自NSNumber類的對象嗎? – LuisEspinoza