How to properly format currency on ios

后端 未结 7 1096
梦谈多话
梦谈多话 2020-12-01 09:19

I\'m looking for a way to format a string into currency without using the TextField hack.

For example, i\'d like to have the number \"521242\" converted into \"5,212

相关标签:
7条回答
  • 2020-12-01 09:49

    Use the following code and it will resolve all your issues....

    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];
    NSString *numberAsString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:[currency doubleValue]]];
    
    0 讨论(0)
提交回复
热议问题