Answer the question
In order to leave comments, you need to log in
How to add spaces to sum using Swift?
Hello. I have a String containing a different amount (1000, 550, 100500, 2000000.50 etc), how can I format this string with Swift 3 to include spaces? 550 => 550, 1000 => 1,000, 100500 => 100,500, 2000000.50 => 2,000,000.50, etc.
This is implemented in Sberbank online and similar applications.
For a long time I searched for an answer on the Internet but could not find anything. Thank you.
Answer the question
In order to leave comments, you need to log in
Good afternoon, what you need is NumberFormatter. It has view settings groupingSeparator
, numberStyle
, which you can use to get what you need:
https://stackoverflow.com/questions/29999024/addin...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question