gpt4 book ai didi

iphone - AFNetworking 在 NSError 对象中返回响应

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

我正在使用 NSURLConnection 来使用服务,现在我正在切换到 AFNetworking,但出现了一些奇怪的错误。我的代码注意:CTHTTPClient是AFHTTPClient的子类

NSDictionary *parameters =  @{
@"email" : @"test@gyc.com",
@"confirmPassword" : @"12345",
@"userName" : @"mithilesh",
@"password" : @"12345",
@"termsAndConditionAccepted" : @1,
@"dob" : @"1190-03-05"
};

[[CTPHTTPClient sharedCTPHTTPClient] postPath:@"signup.json"
parameters:parameters
success: ^(AFHTTPRequestOperation *operation, id JSON){


NSLog(@"Res = %@",JSON);

}
failure:^(AFHTTPRequestOperation *operation, NSError *error){

[CTPUtilities showAlert:[error localizedDescription] delegate:self];
}];

响应

enter image description here

在上面的响应中,您可以看到红色矩形包含有效响应。我在使用 NSURLConnection 时得到了正确的结果。

最佳答案

问题可能是服务器端发送了一个失败的 HTTP 状态代码。尽管您发送的是正确的有效载荷,但您应该根据状态代码而不是有效载荷的内容来确定请求的状态。 AFNetworking 会为您执行此操作,正如 AFNetworking 错误所说,服务器返回 500。

关于iphone - AFNetworking 在 NSError 对象中返回响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16759630/

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