I am trying to grab the text from a dynamically created text field. I use this to make the text field become and resign first responder:
[(UITextField *)[self.view viewWithTag:0] becomeFirstResponder];
That works fine, but when I try to get the text, the app crashes.
[(UITextField *)[self.view viewWithTag:0] text];
What am I doing wrong?
Do not use the tag 0.
viewWithTag:searches the view hierarchy starting from itself and since all views start with tag 0, it will identify itself as the view to be returned.I suggest that you use a different tag on the text field.