I'm using number formatter to change a value number from a JSON to a number with commas (e.g. 500000
to 500,000
). I think I have it down but I'm getting an error saying:
cannot assign a value of type nsnumber to a value type string
if let supply = json["supply"] as? NSNumber{
var numberFormatter = NSNumberFormatter()
numberFormatter.numberStyle = NSNumberFormatterStyle.DecimalStyle
numberFormatter.stringFromNumber(supply)!
totalXRP.text = supply
}
You have to assign the result of
numberFormatter.stringFromNumber
to your text field: