我在 .m 文件中有一段代码,如下所示:
- (IBAction)btnLogin:(UIButton *)sender
{
NSString *strURL = [NSString stringWithFormat:@"http://www.myworkingdomain.com/fn_checkLogin2.php?name=%@&pass=%@", self.email.text, self.password.text];
// to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
// to receive the returend value
NSString *strResult = [[[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding]autorelease];
if ([strResult isEqualToString:@"0"]) {
UIStoryboard *loginFailStoryBoard = [UIStoryboard storyboardWithName:@"loginFailStoryboard" bundle:nil];
UIViewController *initialFailLogin = [loginFailStoryBoard instantiateInitialViewController];
initialFailLogin.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:initialFailLogin animated:YES];
//NSLog(@"%@", strResult);
} else {
UIStoryboard *memberMenuBoard = [UIStoryboard storyboardWithName:@"memberMenuStoryboard" bundle:nil];
UIViewController *initialMemberMenu = [memberMenuBoard instantiateInitialViewController];
initialMemberMenu.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:initialMemberMenu animated:YES];
//NSLog(@"%@", strResult);
}
NSLog(@"%@", strResult);
}
@end
我试图确定一个人是否输入了正确的电子邮件和密码,然后转到下一个视图。我的'strResult'
日志中有 ,它表明 php 脚本可以正常工作。现在看来,if..else
由于部分原因,该语句不起作用[strResult isEqualToString:@"0"]
有人可以建议我应该在哪里更改以更正此问题,以便当会员使用正确的密码登录时,他可以进入会员视图?
谢谢