SwiftUI Stepper puts "." in Integers

Viewed 58
Stepper(value: $year, in: 2018...2025){Text("Year: \(year)")}

Displays as Year: 2.200 thousand-point with the thousand-point.

How can this thousand-point be avoided?

2 Answers

Instead of String interpolation:

Text("Year: \(year)")

Use String initialiser:

Text("Year: \(String(year))")

You can use alternate constructor for Text:

Text(verbatim: "Year: \(year)")

demo

Related