title: iOS - Swift: Parse signup - new user is saved even though text validation should prevent it
body: <p>Here is my code:</p>
  
  <pre><code>@IBAction func signUp(sender: AnyObject) {
      var user = PFUser()
      user.username = self.userNameTextField.text
      user.password = self.passWordTextField.text
      user.signUpInBackgroundWithBlock {
          (succeeded: Bool!, error: NSError!) -&gt; Void in
          if error == nil  &amp;&amp; (user.username != nil &amp;&amp; user.password != nil) {
              println("Sign Up successfull")                 
  
              //Go to main menu
              self.performSegueWithIdentifier("go-to-main-menu", sender: nil)
          } else {
              let errorString = error.localizedDescription
              let alert = UIAlertView()
              alert.title = "Invalid Signup"
              alert.message = "Sorry, a username (unique) and a password are required to create a new account."
              alert.addButtonWithTitle("OK")
              alert.show()
              println(errorString)
          }
      }
  }
  </code></pre>
  
  <p>So my goal is to prevent signup if <br>
  (a) usnername is taken<br>
  (b) username <strong>or</strong> password are not filled in</p>
  
  <p>Results:<br>
  1. Trying to sign up with both fields blank results in the alert<br>
  2. Trying to sign up with password blank results <strong>no</strong> alert and the user is saved<br>
  3. Trying to sign up with username blank  results in the alert</p>
  
  <p>Why is result #2 happening since I am checking for <code>nil</code> in the <em>if statement</em>?</p>
  
  <p>Now, if I change the validation to check for to check for <em>zero</em> length strings:</p>
  
  <pre><code>if error == nil &amp;&amp; (user.username != "" &amp;&amp; user.password != "")
  </code></pre>
  
  <p>...it crashes with this error: </p>
  
  <pre><code>fatal error: unexpectedly found nil while unwrapping an Optional value
  (lldb)
  </code></pre>
  
  <p>...on this line:</p>
  
  <pre><code>let errorString = error.localizedDescription
  </code></pre>
  
  <p>I have looked at <a href="https://stackoverflow.com/questions/13172858/how-to-add-extra-attribute-to-parse-signup-function">how to add an extra attribute to Parse a Signup function</a>, but that's adding extra which I do not want or need.<br>
  I've also looked at "<a href="https://stackoverflow.com/questions/24779837/parse-signup-failure-adds-user-regardless">Parse SignUp Failure Adds User Regardless</a>" but I'm already doing the text check.  </p>