Last active
May 31, 2021 08:05
-
-
Save kyungpyoda/c233221a4bc35905439ad7236d315484 to your computer and use it in GitHub Desktop.
Money Format with Thousand Separator
This file contains hidden or 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
extension String { | |
func toMoneyFormat() -> String { | |
guard let amount = Int(self) else { return self } | |
let formatter = NumberFormatter() | |
formatter.numberStyle = .decimal | |
return formatter.string(for: amount) ?? self | |
} | |
} |
Author
kyungpyoda
commented
May 21, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment