Get currency symbols from currency code with swift

前端 未结 11 676
星月不相逢
星月不相逢 2020-12-24 12:21

How can I get the currency symbols for the corresponding currency code with Swift (macOS).

Example:

  • EUR = €1.00
  • USD = $1.00<
11条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-24 13:12

    To simply get the currency symbol in Swift.

    let locale = Locale.current // currency symbol from current location
    //let locale = Locale(identifier: "fr_FR") // or you could specify the locale e.g fr_FR, en_US etc
    let currencySymbol = locale.currencySymbol!
    
    print("\(currencySymbol)")
    

提交回复
热议问题