I'm currently developing an application for iOS and I recently updated to the iOS 17 beta
along with Xcode 15.0 beta
. I am trying to use NumberFormatter
to format a Double
to a currency string (in my case, American Dollars $). Here is the snippet of my code:
let formatter = NumberFormatter()
formatter.currencySymbol = Locale.current.currencySymbol
print(Locale.current.currency)
print(Locale.current.currencySymbol)
print(Locale.current.currency?.identifier)
print(Locale.current)
formatter.numberStyle = .currency
When running this on iOS 16, I get the following output:
Optional(Foundation.Locale.Currency(_identifier: "USD", _normalizedIdentifier: "usd"))
Optional("$")
Optional("USD")
en_US (current)
However, when running the same code on iOS 17 beta, the output is different:
nil
Optional("¤")
nil
en_001 (fixed)
It appears that the Locale's currency and identifier properties are returning nil, and the Locale itself is being identified differently.
Has anyone else encountered this issue with iOS 17 beta and Xcode 15.0 beta? Is this a bug in the beta versions, or have there been changes in the way Locale should be used for currency formatting?