I'm trying to pass the value in my textfield to another view using delegates. This is how I tried to achieve that..
In the 2nd view from where the value is to be passed to main view, this is what I have written..
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if let _ = raDelegate {
raDelegate?.durationChanged(hrs: string)
}
return true
}
And in the first view, this is what I have...
func durationChanged(hrs: String) {
myView.durationTextField.text = hrs
}
Now the issue is that if I type in say "5" in the textfield, in the durationChanged
function, on applying breakpoint, I get the value in hrs
as "5" itself. But when I remove the breakpoint and run, then what gets finally printed to myView.durationTextField.text
is 55
. Also if I print "7" after that, the "55" gets replaced by "77". While ideally what I should have got was "57".