Ios 将GCD与也进行异步调用的代码一起使用安全吗

Ios 将GCD与也进行异步调用的代码一起使用安全吗,ios,objective-c,asynchronous,afnetworking,grand-central-dispatch,Ios,Objective C,Asynchronous,Afnetworking,Grand Central Dispatch,我有一个为HTTP请求构建数据的应用程序,目前请求本身(使用AFNetworking)也是方法的一部分,该方法将由dispatch\u async包装。重构东西以便不包装AFNetworking调用是否更好 // expensive set up code then... AFHTTPRequestOperation *requestOperation = [manager HTTPRequestOperationWithRequest:request

我有一个为HTTP请求构建数据的应用程序,目前请求本身(使用AFNetworking)也是方法的一部分,该方法将由
dispatch\u async
包装。重构东西以便不包装AFNetworking调用是否更好

// expensive set up code then...
AFHTTPRequestOperation *requestOperation =
            [manager HTTPRequestOperationWithRequest:request
                                             success:^(AFHTTPRequestOperation *operation, id responseObject) {
                                                 NSLog(@"response %@", responseObject);
                                                 success(responseObject);
                                             } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                                                 NSLog(@"error %@", error);
                                                failure(error);
                    }];

    requestOperation.responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingMutableContainers];

    [[NSOperationQueue mainQueue] addOperation:requestOperation];
    return requestOperation;

不管你叫它什么线。AFNetworking将在自己的队列上创建请求操作,并调用主队列上的完成处理程序