How do I get the currency symbol in Swift 3?
public class Currency: NSObject {
public let name: String
public let code: String
public var symbol: String {
return NSLocale.currentLocale().displayNameForKey(NSLocaleCurrencySymbol, value: code) ?? ""
}
// MARK: NSObject
public init(name: String, code: String) {
self.name = name
self.code = code
super.init()
}
}
I know NSLocale got renamed to Locale, but displayNameForKey got removed and I only seem to be able to use localizedString(forCurrencyCode: self.code) to generate the name of the currency in the current locale without being able to get its symbol. I'm looking for a way to get a foreign currency symbol in a current locale.
Or am I overlooking something?