gpt4 book ai didi

ios - 发送用户名和密码后收到服务器响应,但我无法验证登录页面中的响应?

转载 作者:行者123 更新时间:2023-11-28 23:56:11 25 4
gpt4 key购买 nike

我在发送用户名和密码后收到了服务器的响应,但我无法在登录页面中验证响应。

我收到以下回复。

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager POST:urlStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(@"String%@",urlStr);
_responceString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];

NSError *localError = nil;
if ([_responceString isEqual:@"fail"]) {
NSLog(@"Do Nothing");
} else {
NSDictionary *studData = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:&localError];
NSLog(@"response == %@", studData);

_userDetailsString = [studData valueForKey:@"category"];
_messageArray=[_userDetailsString valueForKey:@"Message"];
_usernameArray=[_userDetailsString valueForKey:@"First_Name"];
_resultArray=[_userDetailsString valueForKey:@"result"];





// _resultArray = [[studData valueForKey:@"category"] valueForKey:@"result"];

NSLog(@" value is %@", _resultArray);


if ([_resultArray isEqualToString:@"Success"]) {
NSLog(@"response == %@", _resultArray);




[self.activityIndicatorView stopAnimating];
_objHomeviewcontroller=(HomeViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

[self.navigationController pushViewController:_objHomeviewcontroller animated:YES];

}
else
{
[self.activityIndicatorView stopAnimating];

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Alert" message: @"invalid data" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self dismissViewControllerAnimated:YES completion:nil];
}]];

[self presentViewController:alertController animated:YES completion:nil];


}

响应:

response == {
category = (
{
"First_Name" = Sahithi;
"Last_Name" = L;
"branch_id" = "05/10/2018 13:11:27 PM";
result = Success;
roles = Parent;
}
);
}

最佳答案

看看这是否有帮助。您正在寻找结果属性。如果它等于Success,您可以移动到下一个 View Controller 。

If( [[[[studData valueForKey:@"category"] firstObject] objectForKey:@"result"] isEqualToString: @"Success"]) {

// goto the next view controller
_objHomeviewcontroller=(HomeViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

[self.navigationController pushViewController:_objHomeviewcontroller animated:YES];

} else { // goto another view controller}

关于ios - 发送用户名和密码后收到服务器响应,但我无法验证登录页面中的响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51230328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com