我的代码有问题。我与我的 wep.api 有一个帖子连接,它工作得很好。我收到我输入的消息。我正在尝试对从 web.api 获得的 json 响应进行字符串化,并通过字符串进行比较以查看用户是否转到下一页。问题是即使我输入的信息是错误的,我仍然会被发送到下一页。这是我的代码
[5:39:03 PM] Marco Tejada: -(void) connectionDidFinishLoading:(NSURLConnection *) connection {
NSLog(@"DONE. Received Bytes: %d", [webData length]);
NSString *theJson = [[NSString alloc]
initWithBytes: [webData mutableBytes]
length:[webData length]
encoding:NSUTF8StringEncoding];
NSScanner *scanner1 = [NSScanner scannerWithString:theJson];
NSLog(@"%@", theJson);
if ([scanner1 scanUpToString:@"{\"ResultCode\": 0,\"ResultMessage\": \"Success log in\"}" intoString: NULL])
{
[self performSegueWithIdentifier:@"sesepuede"sender:self];
}
else {
NSLog(@"Username not found");{
}
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Try Again" message:@"Credentials are incorrect" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
[message show];
}
}
@end
有谁知道错误是什么?