title: Best way to count length of UITextInput text value in Swift?
body: <p>I have two UITextInput controls that I want to count the number of characters in.</p>
  
  <p>For context, I have two inputs: one for email address and one for password. I also have a “Login” button. The button is inactive by default, but as soon as at least one character is entered into both inputs, I’ll programatically enable the button. This is to prevent login attempts until the user has entered a value in both fields.</p>
  
  <p>So far, I’m using this approach:</p>
  
  <pre><code>if count(emailInput.text) &gt; 0 &amp;&amp; count(passwordInput.text) &gt; 0 {
      // Enable button
  } else {
      // Disable button
  }
  </code></pre>
  
  <p>Is using the <code>count()</code> function acceptable? Or is there a better way? As I recall there are some gotchas with checking the length of strings in iOS/Swift.</p>