gpt4 book ai didi

ios - 调用 AFNetworking 响应失败 block 而不是成功 block

转载 作者:可可西里 更新时间:2023-11-01 04:24:59 26 4
gpt4 key购买 nike

当我收到状态代码 200 时,AFNetworking 响应 failure block 被调用。我怎样才能让 success 被调用?

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://128.199.94.58/test/bt/client_token.php" parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.clientToken = responseObject[@"customerID"];
NSLog(@"Client Token received.");
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// Handle failure communicating with your server
NSLog(@"Client Token request failed.%@",operation.responseString);
NSLog(@"error code %ld",(long)[operation.response statusCode]);
}];

最佳答案

查看error的值。它会告诉您连接失败的原因。此上下文中的“失败”与状态代码无关。返回“404”仍然是“成功”。失败意味着您无法完成操作。

关于ios - 调用 AFNetworking 响应失败 block 而不是成功 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30237558/

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