Is it possible to derive currency symbol from currency code?

前端 未结 5 1600
鱼传尺愫
鱼传尺愫 2021-02-04 19:04

My iPhone app formats an NSDecimalNumber as a currency using setCurrencyCode, however another screen displays just the currency symbol. Rather than storing both the currency cod

5条回答
  •  抹茶落季
    2021-02-04 19:23

    NSNumberFormatter * formatter = [NSNumberFormatter new];
    formatter.numberStyle = NSNumberFormatterCurrencyStyle;
    
    NSString * localeIde = [NSLocale localeIdentifierFromComponents:@{NSLocaleCurrencyCode: currencyCode}];
    formatter.locale = [NSLocale localeWithLocaleIdentifier:localeIde];
    
    NSString * symbol = formatter.currencySymbol;
    

提交回复
热议问题