I need to show currency list so that user could select one. I want to include all currencies supported by iOS.
Is there a way in iOS to get codes and names for all supported currencies?
Thanks in advance!
I need to show currency list so that user could select one. I want to include all currencies supported by iOS.
Is there a way in iOS to get codes and names for all supported currencies?
Thanks in advance!
Here you are:
NSLocale *locale = [NSLocale currentLocale];
for (NSString *code in [NSLocale ISOCurrencyCodes]) {
NSLog(@"%@ : %@", code, [locale displayNameForKey:NSLocaleCurrencyCode value:code]);
}
let currencies = Locale.isoCurrencyCodes
Array of all unique currencies:
let list = ["AED - AED","AFN - ؋","ALL - ALL","AMD - ֏","ANG - ANG","AOA - Kz","ARS - $","AUD - $","AWG - AWG","AZN - ₼","BAM - KM","BBD - BBD","BDT - ৳","BGN - BGN","BHD - د.ب.","BIF - FBu","BMD - $","BND - $","BOB - Bs","BRL - R$","BSD - $","BTN - Nu.","BWP - P","BYN - Br","BZD - $","CAD - CA$","CDF - FC","CHF - CHF","CLP - $","CNY - ¥","COP - $","CRC - ₡","CUP - $","CVE - ","CZK - CZK","DJF - Fdj","DKK - DKK","DOP - RD$","DZD - DA","EGP - ج.م.","ERN - Nfk","ETB - Br","EUR - €","FJD - $","FKP - FKP","GBP - £","GEL - ₾","GHS - GH₵","GIP - £","GMD - GMD","GNF - GNF","GTQ - Q","GYD - GYD","HKD - HK$","HNL - L","HRK - HRK","HTG - HTG","HUF - Ft","IDR - Rp","ILS - ₪","INR - ₹","IQD - د.ع.","IRR - ریال","ISK - ISK","JMD - $","JOD - د.أ.","JPY - ¥","KES - Ksh","KGS - сом","KHR - ៛","KMF - CF","KPW - KPW","KRW - ₩","KWD - د.ك.","KYD - KYD","KZT - ₸","LAK - ₭","LBP - ل.ل.","LKR - රු.","LRD - $","LYD - د.ل.","MAD - MAD","MDL - L","MGA - Ar","MKD - ден","MMK - K","MNT - ₮","MOP - MOP$","MRU - أ.م.","MUR - Rs","MVR - ރ.","MWK - MK","MXN - $","MYR - RM","MZN - MTn","NAD - $","NGN - ₦","NIO - C$","NOK - NOK","NPR - नेरू","NZD - $","OMR - ر.ع.","PAB - B/.","PEN - S/","PGK - K","PHP - ₱","PKR - ر","PLN - zł","PYG - Gs.","QAR - ر.ق.","RON - RON","RSD - RSD","RUB - RUB","RWF - RF","SAR - ر.س.","SBD - $","SCR - SR","SDG - ج.س.","SEK - kr","SGD - $","SHP - £","SLL - SLL","SOS - S","SRD - SRD","SSP - £","STN - Db","SYP - LS","SZL - E","THB - ฿","TJS - сом.","TMT - TMT","TND - DT","TOP - T$","TRY - ₺","TTD - TTD","TWD - $","TZS - TSh","UAH - UAH","UGX - USh","USD - $","UYU - $","UZS - soʻm","VND - ₫","VUV - VT","WST - WS$","XAF - FCFA","XCD - $","XOF - CFA","XPF - FCFP","YER - ر.ي.","ZAR - R","ZMW - K"]
Here you are:
NSLocale *locale = [NSLocale currentLocale];
for (NSString *code in [NSLocale ISOCurrencyCodes]) {
NSLog(@"%@ : %@", code, [locale displayNameForKey:NSLocaleCurrencyCode value:code]);
}
You can get the list of all ISO codes using Locale
.
Below code returns all the ISO codes for currency as array of String.
Locale.isoCurrencyCodes
You can also copy below snippet into your code
struct Currency {
let name: String
let code: String
}
extension Currency {
static var allCurrencies: [Currency] {
let currencies: [Currency] = Locale.isoCurrencyCodes.compactMap {
guard let name = Locale.current.localizedString(forCurrencyCode: $0) else {
return nil
}
return Currency(name: name, code: $0)
}
return currencies
}
}
This will give you a list of all currencies as Currency type and you can easily access name, code. Additionally you can append symbols too if needed.
Locale.isoCurrencyCodes
is deprecated as of iOS 16.0. –
Marras © 2022 - 2024 — McMap. All rights reserved.
Locale.isoCurrencyCodes
is deprecated as of iOS 16.0. – Marras