8

ユーザーが選択できるように、通貨リストを表示する必要があります。iOSでサポートされているすべての通貨を含めたいです。

iOSで、サポートされているすべての通貨のコードと名前を取得する方法はありますか?

前もって感謝します!

4

3 に答える 3

8

はい、どうぞ:

NSLocale *locale = [NSLocale currentLocale];
for (NSString *code in [NSLocale ISOCurrencyCodes]) {
    NSLog(@"%@ : %@", code, [locale displayNameForKey:NSLocaleCurrencyCode value:code]);
}
于 2013-01-15T18:23:16.040 に答える
8

スウィフト5

let currencys = Locale.isoCurrencyCodes

すべての一意の通貨の配列:

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"]
于 2019-12-16T13:57:40.193 に答える
0

を使用して、すべてのISOコードのリストを取得できますLocale

以下のコードは、通貨のすべてのISOコードを文字列の配列として返します。

Locale.isoCurrencyCodes

以下のスニペットをコードにコピーすることもできます

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
    }
}

これにより、通貨タイプとしてすべての通貨のリストが表示され、名前、コードに簡単にアクセスできます。さらに、必要に応じて記号を追加することもできます。

于 2021-11-24T10:01:36.847 に答える