Daniel I
Daniel I

Reputation: 127

How do you reference the input text from a UIAlertController's Text box?

I have a text box within my alert controller in which the user puts in the what they would like to save the object as. I cannot find a way to reference this string the user puts in.

Upvotes: 0

Views: 97

Answers (1)

JAL
JAL

Reputation: 42449

UIAlertController has a textFields property which retains an array of UITextFields used in your alert controller.

Use this property to access the text fields displayed by the alert. The text fields are in the order in which you added them to the alert controller. This order also corresponds to the order in which they are displayed in the alert.

If you have only one UITextField, you can use [alertController.textFields firstObject].text to access the text entered by the user.

Upvotes: 1

Related Questions