You can do it this way:
public func currencyString(_ decimals: Int) -> String {
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.maximumFractionDigits = decimals
return formatter.string(from: NSNumber(value: decimals))!
}
Because if you check NSNumber
you will get predefined init like:
public init(value: Int)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…