Search code examples
iosiphoneobjective-cuitextfielduitextfielddelegate

textFieldDidEndEditing firing "too late"


I have a multiview process the user is entering in data and I'm saving it to the model class properties each step along the way.

I use textFieldDidEndEditing to check if the input is valid, and if so, saves the entered data.

On the view I have a continueButtonClicked event that checks to see if all the validations pass and if so loads the next view. I do NOT set the properties of the model here, because I think I shouldn't have to since each field is saved to the model 1 field at a time. However, I noticed some issues.

If the user is inside of a textbox and clicks the "Continue" button, the continueButtonClicked event fires BEFORE the textFieldDidEndEditing. What ends up happening is that the next view is populated with the "old" model prior to the save happening in textFieldDidEndEditing.

What am I missing? Is it proper to set all the properties on the Continue? That's how I would do it if I were programming for the web, but it doesn't seem right for a native app.


Solution

  • Can you try this instead and see if that solves your problem?

    textFieldShouldEndEditing: