Skip to content

Instantly share code, notes, and snippets.

@kyungpyoda
Last active May 31, 2021 08:05
Show Gist options
  • Save kyungpyoda/c233221a4bc35905439ad7236d315484 to your computer and use it in GitHub Desktop.
Save kyungpyoda/c233221a4bc35905439ad7236d315484 to your computer and use it in GitHub Desktop.
Money Format with Thousand Separator
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
}
}
@kyungpyoda
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment