2015-12-28 65 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