I\'m looking for a way to format a string into currency without using the TextField hack.
For example, i\'d like to have the number \"521242\" converted into \"5,212
func getCurrencyFormat(price:String)->String{
let convertPrice = NSNumber(double: Double(price)!)
let formatter = NSNumberFormatter()
formatter.numberStyle = .CurrencyStyle
formatter.currencyCode = "USD"
let convertedPrice = formatter.stringFromNumber(convertPrice)
return convertedPrice!
}
Note:- A currency code is a three-letter code that is, in most cases, composed of a country’s two-character Internet country code plus an extra character to denote the currency unit. For example, the currency code for the Australian dollar is “AUD”.