I have a UIViewController
which embedded inside another UIViewController
. In this child view controller, there are two UITextField
s which lets the user to enter some data.
How can I pass that data entered in that embedded view controller back to the parent view controller?
I tried to get a reference to the text fields in the child view controller using this method but I get an error.
let textfield: UITextField = self.childViewControllers.last?.usernameTextField! as UITextField
This usernameTextField
is one of the UITextField
s inside that embedded UIViewController
. I get the following error,
'AnyObject' does not have a member named 'usernameTextField'
Is this the best way to do this or are there any other routes I could take to accomplish this?
Thank you.