Hi there, I was searching for the answer and bumped into this just an update since locale.currencyCode is decprecated.
locale.currencyCode is replaced with Locale( identifier: identifier ).currency but it can be nil so I use if let.
I am still a beginner in Swift, please let me know if there is anyting wrong with the code.
func generateCurrencyCode (){
var currencyCode = Set<String>()
for identifier in Locale.availableIdentifiers {
if let locale = Locale( identifier: identifier ).currency {
currencyCode.insert(locale.identifier) // locale returns Currency(_identifier: ____, _normalizedIdentifier: _____ )
}
}
return currencyCode
}
currencyCode will be as follow
["ZMW", "TJS", "COP", "JMD", "CRC", "GMD", "AFN", "FKP", "NAD", "MAD", "AMD", "IRR", "BIF", "QAR", "MXN", "MKD", "MZN", "BRL", "CVE", "BWP", "ETB", "HUF", "SLL", "XCD", "THB", "ALL", "BDT", "XPF", "BBD", "BOB", "BGN", "TZS", "BHD", "MGA", "SHP", "KMF", "KZT", "PAB", "SGD", "AZN", "BMD", "BAM", "KHR", "TOP", "RWF", "AOA", "GNF", "TWD", "HNL", "PKR", "JPY", "PGK", "CDF", "SEK", "TTD", "MRU", "SSP", "PYG", "USD", "MNT", "MMK", "VUV", "BSD", "HKD", "EGP", "LYD", "NGN", "MOP", "ILS", "UGX", "BTN", "UAH", "RON", "LKR", "MDL", "KRW", "NPR", "ANG", "DZD", "RUB", "NZD", "KES", "EUR", "CZK", "XOF", "HTG", "KGS", "SRD", "TND", "KPW", "GHS", "SDG", "NOK", "GEL", "MYR", "LAK", "MUR", "XAF", "IQD", "PHP", "STN", "ARS", "SOS", "INR", "TRY", "GIP", "JOD", "DKK", "SCR", "CAD", "DOP", "KYD", "OMR", "KWD", "CNY", "GBP", "SBD", "GYD", "BZD", "CLP", "NIO", "FJD", "SAR", "DJF", "PEN", "MVR", "SZL", "MWK", "ZAR", "BND", "UYU", "AED", "RSD", "LRD", "AUD", "GTQ", "IDR", "SYP", "LBP", "AWG", "CHF", "YER", "UZS", "ISK", "BYN", "PLN", "CUP", "ERN", "VES", "TMT", "VND", "WST"]
Topic:
App & System Services
SubTopic:
StoreKit
Tags: