jeudi 7 juillet 2016

Input from UITextField connected from storyboard to Swift view controller file


Using Swift, how do I get the input from a UITextField?

In my Main.storyboard, I have chosen a "Text Field" from the premade components and dragged it onto my storyboard.

Now how can I access its value in my ViewController.swift?

What I'm currently doing:

I ctrl+drag the text field into my ViewController.swift file. Then in the popup-box I choose "outlet" and name it "myInput".

Then in another function, I access its value by using self.myInput.text.

Is this the only way to access its input? Is my approach following Swift conventions?


Aucun commentaire:

Enregistrer un commentaire