__block NSInteger outstandingRequests = [requestsArray count];
for (NSURLRequest *request in requestsArray)
{
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
[self parseData:data];
outstandingRequests--;
if (outstandingRequests == 0)
{
[delegate finishApproveRejectAll];
}
}];
}
答案 0 :(得分:2)
如果请求一次多于一个,您应该使用NSOperationQueue
答案 1 :(得分:0)
把它放在.h
上@property(nonatomic,retain)ASINetworkQueue *networkQueue;
设置请求
for (int i=0; i<[RequesttList count]; i++)
{
ASIHTTPRequest *request=[ASIHTTPRequest requestWithURL:[NSURL URLWithString:urlString]];
[request setShouldContinueWhenAppEntersBackground:YES];
request.tag = i;
[[self networkQueue] addOperation:request];
}