0
In the code below removeLast() works on "textField text: $teste"
, but, does not work in the "text: $addCollectionVM.name"
.
The difference between them is that the first is @State and the second @stateObject. Please someone could give me a hint?
NavigationView {
Form {
TextField("Collection Name", text: $addCollectionVM.name)
.onChange(of: self.addCollectionVM.name, perform: { value in
if value.count > 2 {
self.addCollectionVM.name.removeLast()
}
})
TextField("Collection description", text: $addCollectionVM.cDescription)
TextField("Teste", text: $teste)
.onChange(of: self.teste, perform: { inputValue in
if inputValue.count > 2 {
self.addCollectionVM.name.removeLast()
}
})