Search code examples
swiftstringcompiler-errorsiboutlet

Ambiguous reference to member "text"


I have two IBOulets:

@IBOutlet weak var usernameTextField: UITextField!

@IBOutlet weak var passwordTextField: UITextField!

and I want to check if their textfields are blank or not. However, when I invoke the text.isBlank method the compiler shows error "Ambiguous reference to member 'text'"

   if ChatManager.shared.isConnected() {
        ChatManager.shared.disconnect()
        usernameTextField.isHidden = false
        passwordTextField.isHidden = false

    } else {


        guard usernameTextField.text.isBlank == false,
            passwordTextField.text.isBlank == false else {
            return
        }

I also noticed that UITextfield has text : String? or text(UITextRange) : String?


Solution

  • Apparently it was because my OS and Xcode versions were not up to date. After i updated to sierra and used swift 3.1 the error is gone.