iOS開發字符串處理篇之貨幣格式化

1、貨幣格式化orm

  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 //一億二千三百四十五萬六千七百八十九
     */
相關文章
相關標籤/搜索