Hi all,
I am trying to detect when a textfield has changed to run code only in that chase however I am trying to edit existing data so I have to preload the textfield on appear of the editing page and this triggers the .onChange. I have tried to set the variable to false after the data is loaded but it didn’t help. Any help will be appreciated. Thanks
TextField("\(labResults.nickel)", text: $nickelLabResult)
.textFieldStyle(.roundedBorder)
.keyboardType(.decimalPad)
.frame(width: textfieldWidth)
.onChange(of: nickelLabResult) {
nickelChanged = true
}
.onAppear{
if isEditMode {
nickelLabResult = String(labResults.nickel)
}
nickelChanged = false
}