gpt4 book ai didi

ios - AFNetworking 3.0 状态码

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:58:21 24 4
gpt4 key购买 nike

我正在使用 AFNetworking 3.0,但无法获取成功或失败的状态代码。

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:[NSString stringWithFormat:@"%@%@",BASE_URL,url] parameters:parameters progress:^(NSProgress * _Nonnull downloadProgress) {
// TODO: show progress somewhere
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"%@",responseObject);
// get status here
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

// get status here
}];

最佳答案

这是工作代码:

[afHttpSessionManager GET:@"blablabla/bla" parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
// success
} failure:^(NSURLSessionTask *operation, NSError *error) {
// failure
NSHTTPURLResponse *response = (NSHTTPURLResponse *) [operation response];
NSInteger statusCode = [response statusCode];
NSLog(@"RESPONSE CODE: %i", statusCode);
}];

关于ios - AFNetworking 3.0 状态码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34945289/

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