I have a label
that gets info from the previous view controller
as follows
@IBOutlet weak var textField: UITextField!
var label = String()
func textFieldDidBeginEditing(_ textField: UITextField) {
self.textField.text = String(self.label.dropLast())
}
Here is the scenario:
textField on loading: Apple (edit Icon)
textField on editing first time: Apples are healthy
textField on tapping again: Apple
Everything is fine when I start editing textField
but once I tapped outside or go to another field and come back to the textField
, all the editing is gone. How to prevent this from happening?