dimanche 4 novembre 2018

Why a textfield condition is not working in Swift?

ok people, what am I doing wrong? I'm trying to work with an if statement on a text field. If the field is empty I just want to print nil, it not, I want to print the opposite.

For some reason that I don't know, is not working. Please help. This is my code:

import UIKit
import Firebase

class PasswordResetVC: UIViewController {

@IBOutlet var emailTF: UITextField!
@IBOutlet var KeyboardView: UIView!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    addKeyboard(view: KeyboardView)
    emailTF.becomeFirstResponder()

}

func passwordResetEmail() {
    if emailTF == nil {
        print("nil")
    } else {
        print("not nil")
    }
}


@IBAction func goButton(_ sender: Any) {
   passwordResetEmail()
}

}

Aucun commentaire:

Enregistrer un commentaire