【发布时间】:2017-08-26 08:02:22
【问题描述】:
Xcode 显示代码永远不会被执行的警告,但我不明白为什么。任何人都可以启发我吗? (错误发生在内部 if 和 else 语句中,在完成处理程序中,对于两个验证语句)
- (IBAction)siginButtonPressed:(UIButton *)sender
{
if (isLogin)
{
[[FIRAuth auth] signInWithEmail:_usernameTextField.text
password:_passwordTextField.text
completion:^(FIRUser *user, NSError *error)
{
if (FIRAuthErrorCodeUserNotFound)
{
_credentialVerification.text = @"Invalid Credentials";
_entryValidation.text = @"An account with the listed credentials was not found, please proceed to registration screen via the navigation bar at the top of the applications user interface";
}
else
{
/*(Warning 1)*/ _credentialVerification.text = @"Valid Credentials";
[self performSegueWithIdentifier:@"toMainScreen" sender:self];
}
}
];
}
else
{
[[FIRAuth auth] createUserWithEmail:_usernameTextField.text
password:_passwordTextField.text
completion:^(FIRUser *_Nullable user, NSError *_Nullable error)
{
if (FIRAuthErrorCodeInvalidEmail)
{
_credentialVerification.text = @"Invalid Email";
}
else
{
/*(Warning 2)*/ _entryValidation.text = @"Account creation was succesful, please proceed to the login screen via the navigation bar at the top of the applications user interface";
}
}
];
}
}
已编辑:
- (IBAction)siginButtonPressed:(UIButton *)sender
{
if (isLogin)
{
[[FIRAuth auth] signInWithEmail:_usernameTextField.text
password:_passwordTextField.text
completion:^(FIRUser *user, NSError *error)
{
if (error.code == FIRAuthErrorCodeUserNotFound)
{
_credentialVerification.text = @"Invalid Credentials";
_entryValidation.text = @"An account with the listed credentials was not found, please proceed to registration screen via the navigation bar at the top of the applications user interface";
}
else
{
_credentialVerification.text = @"Valid Credentials";
[self performSegueWithIdentifier:@"toMainScreen" sender:self];
}
}
];
}
else
{
[[FIRAuth auth] createUserWithEmail:_usernameTextField.text
password:_passwordTextField.text
completion:^(FIRUser *_Nullable user, NSError *_Nullable error)
{
if (error.code == FIRAuthErrorCodeInvalidEmail)
{
_credentialVerification.text = @"Invalid Email";
}
else
{
_entryValidation.text = @"Account creation was succesful, please proceed to the login screen via the navigation bar at the top of the applications user interface";
}
}
];
}
}
【问题讨论】:
-
这个警告在哪一行?
-
我将编辑代码以显示警告出现的位置。
-
@AdityaSrivastava 您现在应该能够看到更新的代码,其中显示了两个错误的位置。注意:else 语句中的所有内容在技术上都适用于这个“代码永远不会被执行”错误,所以编辑里面的内容不会产生任何结果,我相信外部语法有问题。
-
发表了我的答案。检查一下
标签: ios objective-c firebase firebase-authentication