'How to display an int without commas?

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!



Solution 1:[1]

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)")

backup

Solution 2:[2]

Use Text(String(yourIntValue)) if you use interpolation you need to cast it as a string directly. If you allow the int to handle it, it shows with a ,.

So to recap.

let yourIntValue = 1234
Text(String(yourIntValue)) // will return `1234`.
Text("\(yourIntValue)") // will return `1,234`.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 xTwisteDx