-2

I am getting this error on my if statement.

CODE:

-(IBAction)login:(id)sender
{

    NSString *correctUser = @"money";
    NSString *correctPassword = @"ilovemoney";

    if ((usernameTextField.text == correctUser)==YES && (passwordTextField.text = correctPassword)==YES) //error is on the beginning of this if statement.
    {
        [self performSegueWithIdentifier:@"oneTransition" sender:sender];
    }

}
benr783
  • 63
  • 4

1 Answers1

4

There are a bunch of problems here.

  • You're using = instead of == in your second test, which is assignment, not comparison; this is why you're getting the warning.

  • Comparing strings with == doesn't do what you want. You should use [usernameTextField.text isEqual:correctUser], for example.

  • You should never compare something to YES as in == YES. So, instead of if (something == YES) just say if (something).

Jesse Rusak
  • 56,530
  • 12
  • 101
  • 102