我正在使用 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/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |