So I'm trying to get the text of an input field in Swift. So here's what I got
class ViewController: UIViewController {
@IBOutlet var passwordField: UITextField!
@IBOutlet var usernameField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
//Try to log user in by default
let user = usernameField.text
let password = passwordField.text
It all looks good (I know I didn't close the class, I just pulled it directly out) and when I go to run it, I get
fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)
and
(You'll have to open the image in a new tab to see it)
I binded the input fields with the IBOutlet successful, I know that. Any ideas?