iOS开发字符串处理篇之货币格式化
一、货币格式化
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init]; currencyFormatter.numberStyle = kCFNumberFormatterDecimalStyle; NSString *currenctStr = [currencyFormatter stringFromNumber:[NSNumber numberWithInteger:currencyNumber]]; return [NSString stringWithFormat:@"¥%@",currenctStr];//因为我需要的样式是¥123,456,789没有后面的.00 /* NSNumberFormatterNoStyle = kCFNumberFormatterNoStyle, // 123456789 NSNumberFormatterDecimalStyle = kCFNumberFormatterDecimalStyle,// 123,456,789 NSNumberFormatterCurrencyStyle = kCFNumberFormatterCurrencyStyle,//¥123,456,789.00 NSNumberFormatterPercentStyle = kCFNumberFormatterPercentStyle, //-539,222,988% NSNumberFormatterScientificStyle = kCFNumberFormatterScientificStyle,//1.23456789E8 NSNumberFormatterSpellOutStyle = kCFNumberFormatterSpellOutStyle //一亿二千三百四十五万六千七百八十九 */
将来的自己,会感谢现在不放弃的自己!