Xcode 8.0 (8A218a) GM
Target : iOS 10 (Swift 3)
Consider the following code:
let number = NSDecimalNumber(decimal: 22.4) let numberFormatter = NumberFormatter() numberFormatter.numberStyle = .currency numberFormatter.locale = Locale.current let result = numberFormatter.string(from: number) print(result!)
Result:
¤22.40
(I don't know what ¤ means.)
But if I initialize the locale, for example:
numberFormatter.locale = Locale(identifier: "en_US")
The result will be:
$22.40
... this is what I expect in the first place.
Please note that this works on the tho playground:

The problem seems to only happen on devices / simulators with the launch of Xcode.
(I tested on two different macOS - at my workplace and at home.)
Any ideas on what's going on?
ios ios10 swift3 locale nsnumberformatter
backslash-f
source share