Objective c 函数的隐式声明';如果';是否在C99中无效?

Objective c 函数的隐式声明';如果';是否在C99中无效?,objective-c,Objective C,我试图为我的应用程序创建一个注册页面,当我创建“如果”语句时,我遇到了一个C99错误。我使用的是xCode 5.1.1,我使用的是parse SDK和框架。我不太清楚我做错了什么,但如果这是一个非常明显的错误,我道歉 - (IBAction)continueAction:(id)sender { [_usernameField resignFirstResponder]; [_emailField resignFirstResponder]; [_passwordFiel

我试图为我的应用程序创建一个注册页面,当我创建“如果”语句时,我遇到了一个C99错误。我使用的是xCode 5.1.1,我使用的是parse SDK和框架。我不太清楚我做错了什么,但如果这是一个非常明显的错误,我道歉

- (IBAction)continueAction:(id)sender {
    [_usernameField resignFirstResponder];
    [_emailField resignFirstResponder];
    [_passwordField resignFirstResponder];
    [_retypeField resignFirstResponder];
    [self checkFieldsComplete];
}

- (void) checkFieldsComplete {
    If ([_usernameField.text isEqualToString:@""] || [_emailField.text isEqualToString:@""] || [_passwordField.text isEqualToString:@""] || [_retypeField.text isEqualToString:@""]); { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Woaaahhhh, hold on there" message:@"You must complete all fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
     {
        [self checkPasswordsMatch];
    }

}

- (void) checkPasswordsMatch {
    if (![_passwordField.text isEqualToString:_retypeField.text]) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Woaaahhhh" message:@"Passwords don't match" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
    else {
        [self registerNewUser];
    }
}

问题出在这一行:

If ([_usernameField.text isEqualToString:@""] || [_emailField.text isEqualToString:@""] || [_passwordField.text isEqualToString:@""] || [_retypeField.text isEqualToString:@""]); { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Woaaahhhh, hold on there" message:@"You must complete all fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
If
重命名为
If
。C关键字和标识符区分大小写。另外,删除if语句后的分号。如果希望在if语句为false时执行第二个块,则还需要插入
else
。总的来说,它应该是这样的:

if ([_usernameField.text isEqualToString:@""] || [_emailField.text isEqualToString:@""] || [_passwordField.text isEqualToString:@""] || [_retypeField.text isEqualToString:@""])
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Woaaahhhh, hold on there" message:@"You must complete all fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
}
else
{
    [self checkPasswordsMatch];
}

非常感谢。我知道这是一个明显的错误。我想我需要多加注意