ASINetworkQueue  队列下载

需要导入ASIHTTPRequest第三方库

#import "ViewController.h"

#import "ASIHTTPRequest.h"

#import "ASINetworkQueue.h"


@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

    

    ASINetworkQueue* queue = [[ASINetworkQueue alloc] init];

    //最大同时进行数 始终有多少个在下载

    queue.maxConcurrentOperationCount = 5;

    for (int i = 0; i < 100; i++) {

        ASIHTTPRequest* request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://10.0.8.8/sns/my/user_list.php"]];

        [queue addOperation:request];

    }

    //开始

    [queue go];

    

    

    

    NSOperationQueue* oQueue = [[NSOperationQueue alloc] init];

    oQueue.maxConcurrentOperationCount = 5;

    NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://10.0.8.8/sns/my/user_list.php"]];

    [NSURLConnection sendAsynchronousRequest:request queue:oQueue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

        

    }];

}








@end


你可能感兴趣的:(ASINetworkQueue  队列下载)