I'm using Xcode 14 and I have a text that has o show a int value that represent the current year so in my view-model I found the year in that way
@Published var selectedYear: Int = Calendar.current.component(.year, from: Date())
and after I put the variable in the text
Text("\(vm.selectedYear)")
but in the view it is shown like this : 2,022 instead of 2022 and I don't understand why
it seams only a problem on representation in text because if printed it show 2022
thanks
CodePudding user response:
try this, works for me:
Text(String(vm.selectedYear))
See also this post: String interpolation in Swift for how to use custom interpolations