Skip to content

Instantly share code, notes, and snippets.

@ashour
Created April 24, 2019 11:32
Show Gist options
  • Save ashour/3daa9ae5d6e36b86ac39f56b5e2a487b to your computer and use it in GitHub Desktop.
Save ashour/3daa9ae5d6e36b86ac39f56b5e2a487b to your computer and use it in GitHub Desktop.
import Foundation
func centsToString(_ cents: Int) -> String
{
let dollars = Double(cents) / 100.0
let formatter = NumberFormatter()
formatter.numberStyle = .currency
// This next line is added as a fix
formatter.currencyCode = "US$"
return formatter.string(from: NSNumber(value: dollars))!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment