Is there a simple way to format currency into string in iOS?

前端 未结 7 1082

I need a way to format the price from NSNumber into a string like this: \"USD 0.99\", not \"$ 0.99\".

My game uses custom fonts, and they could not have the symbols

7条回答
  •  执笔经年
    2020-12-23 15:59

    use formatter in this way or you can also customize it

    NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
    [numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];
    

    or like this

    [formatter setFormat:@"USD ###.00"];
    

    i think you can check the currency for the country and store that in string and give that to the formatter.

提交回复
热议问题