AFHTTPSessionManager 成功回调在主线程

AFHTTPSessionManager success callback are in main thread

我有一个使用 AFHTTPSessionManager 的请求:

    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [manager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"username" password:@"password"];

    [manager GET:[NSString stringWithFormat:@"%@post/%ld",C_baseURL,(long)post_id] parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {

        // this called not in main thread

    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

        //  this called in main thread

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        //  this called in main thread

    }];

我检查 successfailure 回调是否在主线程中。
如何使这些回调在主线程中不像 progress 回调那样 运行?

您可以设置 operationQueue 选择委托方法的调用方式,设置 completionQueue 选择完成块的调用方式。