string - How to deal with separator format in Swift 3 -
having great deal of trouble finding way (formating) remove comma , if no comma found leave is.
what hoping achieve taking result of distance , displaying in label format is:
4589.163
instead of
4,589.163
if no comma separator found leave
479.996
my code:
if tempdistancestring.contains(",") { let newstring = tempdistancestring.replacingoccurrences(of: ",", with: "") }
i'm looking formatter if supportable requirement.
any appreciated.
swift 3.1
just replace occurrences of comma blank string.
let astring = "4,589.163" let newstring = astring.replacingoccurrences(of: ",", with: "")
Comments
Post a Comment