Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display an int without commas?

Tags:

swift

swiftui

I have a list of Text views that include a year saved as an int. I'm displaying it in an interpolated string:

Text("\($0.property) \($0.year) \($0.etc)")

The problem, it adds a comma to the int, for example it displays 1,944 instead of the year 1944. I'm sure this is a simple fix but i've been unable to figure out how to remove the comma. Thanks!

like image 527
Thomas Avatar asked Dec 14 '22 07:12

Thomas


1 Answers

There is explicit Text(verbatim:) constructor to render string without localization formatting, so a solution for your case is

Text(verbatim: "\($0.property) \($0.year) \($0.etc)")
like image 157
Asperi Avatar answered Jan 15 '23 01:01

Asperi