I have an app where I'm trying to format a Double
with NumberFormetter
but the output I'm getting does not match the output in other apps.
Here is the code I'm using...
let price:Double = 25
let currencyFormatter = NumberFormatter()
currencyFormatter.usesGroupingSeparator = true
currencyFormatter.numberStyle = .currency
currencyFormatter.locale = NSLocale.current
let priceFormatter = currencyFormatter.string(for: price)
myLabel.text = priceFormatter
With the above code and with the phone's Region
set to China in my App I get 25,00 CNY
but in two other third-party-apps the output is CN¥25.00
.
What am I doing wrong?
My App
25,00 CNYOther Apps
CN¥25.00
My App
25,00€Other Apps
€25,00
But when the region is set to United States
I get the same notation in all three (3) apps.
My App
$25.00Other Apps
$25.00
I'm a little concerned especially with the output when the region is set to China because besides the notation being different I also get a different symbol CNY
vs CN¥
.
Any suggestions, am I doing something wrong?
Spoiler the other apps are doing it wrong, your output is correct !