title: Focus password textfield in UIAlertView
body: <p>I'm trying to set the initial focus inside a UIAlertView to the password field, but all I've tried so far didn't work.</p>
  
  <p>I was hoping that this code works but there's a mistake that I can't figure out:</p>
  
  <pre><code>- (void)showLoginFormWithUsername:(NSString*)username andPassword:(NSString*)password {
      UIAlertView *loginView = [[UIAlertView alloc] initWithTitle:@"Login"
                                                          message:@"Please enter your login data."
                                                         delegate:self
                                                cancelButtonTitle:@"Cancel"
                                                otherButtonTitles:@"Login", nil];
  
      loginView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
  
      // get TextFields
      UITextField *usernameField = [loginView textFieldAtIndex:0];
      UITextField *passwordField = [loginView textFieldAtIndex:1];
  
      // set text
      if (username)
          usernameField.text = username;
      if (password)
          passwordField.text = password;
  
      // set focus
      if (usernameField.hasText &amp;&amp; !passwordField.hasText)
          [passwordField becomeFirstResponder];
  
      [loginView show];
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>