Get list of supported currencies in iOS
Asked Answered
T

3

9

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!

Thermae answered 17/10, 2012 at 13:27 Comment(0)
K
8

Here you are:

NSLocale *locale = [NSLocale currentLocale];
for (NSString *code in [NSLocale ISOCurrencyCodes]) {
    NSLog(@"%@ : %@", code, [locale displayNameForKey:NSLocaleCurrencyCode value:code]);
}
Kindliness answered 15/1, 2013 at 18:23 Comment(0)
K
10

Swift 5

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"]
Ketose answered 16/12, 2019 at 13:57 Comment(3)
Locale.isoCurrencyCodes is deprecated as of iOS 16.0.Marras
@Marras what should we use then?Construct
Found this developer.apple.com/documentation/foundation/locale/… . Not sure if it's equivalent though.Construct
K
8

Here you are:

NSLocale *locale = [NSLocale currentLocale];
for (NSString *code in [NSLocale ISOCurrencyCodes]) {
    NSLog(@"%@ : %@", code, [locale displayNameForKey:NSLocaleCurrencyCode value:code]);
}
Kindliness answered 15/1, 2013 at 18:23 Comment(0)
D
1

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.

Devilish answered 24/11, 2021 at 10:1 Comment(1)
Locale.isoCurrencyCodes is deprecated as of iOS 16.0.Marras

© 2022 - 2024 — McMap. All rights reserved.