Created
April 24, 2019 11:32
-
-
Save ashour/3daa9ae5d6e36b86ac39f56b5e2a487b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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