2015-12-28 120 views
0

隨着AFNetworking 3如何添加依賴? 這些請求必須按照順序工作... 我有這樣的事情在for循環中,但當然,如果一個GET請求之前完成其他的整個序列是錯誤的。AFNetworking 3添加依賴?

AFHTTPSessionManager *manager = [self sessionManager]; 
[manager.operationQueue setMaxConcurrentOperationCount:1]; 
NSString *url = [_hostName.absoluteString stringByAppendingPathComponent:keyboardPath]; 
[manager GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { 

    //do something 

} // ... failure block 

在AFNetworking 2我用來做這樣的事情:

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request]; 
[operation addDependency... 

但現在AFHTTPRequestOperation不存在了......

回答

0

你不能,你必須包裝NSURLSessionTask進入NSOperation。你也可以使用涼的NSOperation包裝這將允許你做更多:https://github.com/inspace-io/INSOperationsKit

+0

沒用過這個包裝......你能不能給我說說NSURLSessionTask一些代碼做我想做什麼? – Fabiosoft

+0

https://github.com/inspace-io/INSOperationsKit/blob/master/Shared%20INSOperationKit%20Demo%20Code/Operations/INSDownloadOperation.m – mientus

+0

我不能讓它的工作......你有一個實際的例子? – Fabiosoft