我有一个使用 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
}];
我检查success
andfailure
回调是否在主线程中。
如何使这些回调不像回调那样在主线程中运行progress
?