resignFirstResponder only if all textFields are filled
<p>I want to <code>resignFirstResponder()</code> for one <code>textField</code> only if all <code>textFields</code> are filled. However for some reason it doesn't work. No matter if others are filled, it only checks for the one responder one.</p>

<p>This is what I am trying to do:</p>

<pre><code>//Check wheather fields are filled or not and then enable or disable register button
    func textChanged(_ sender: NSNotification) {
        if usernameField.hasText &amp;&amp; emailField.hasText &amp;&amp; passwordField.hasText &amp;&amp; confirmPasswordField.hasText {
            registerButton.isEnabled = true
            confirmPasswordField.resignFirstResponder()
        }
        else {
            registerButton.isEnabled = false
        }
    }
</code></pre>

<p>And I also tried:</p>

<pre><code>func textFieldShouldReturn(textField: UITextField!) -&gt; Bool {
        if usernameField.hasText &amp;&amp; emailField.hasText &amp;&amp; passwordField.hasText &amp;&amp; confirmPasswordField.hasText {
        confirmPasswordField.resignFirstResponder()
            return true
        }
        return false
    }
</code></pre>

<p>What I am doing wrong?</p>