My apps need to download many files and I use a for loop to create download tasks. Following method is the one provided by AFNetworking.

```
- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request
                                         progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock
                                      destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
                                completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler{
__block NSURLSessionDownloadTask *downloadTask = nil;
url_session_manager_create_task_safely(^{
    downloadTask = [self.session downloadTaskWithRequest:request];
});

[self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler];

return downloadTask;

```

}

My codes would be like:

```
for (NSInteger i = 0; i<= 500; i++) {
    NSMutableURLRequest *request = array[i];

    NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:downloadProgress destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
        return destinationPath;
    } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
        completionBlock(filePath,error);
    }];

    [downloadTask resume];
}

```

The problem is

```
downloadTask = [self.session downloadTaskWithRequest:request];

```

this line takes relatively long to done, which means if excute it for 500 times, it gonna take 5~6 seconds.

My app pop up an alertView to ask users whether to download, and if they tap Yes, it will do something like the for loop and as a result the UI will stuck there for 5~6 seconds until all the tasks are created.

I am not sure if I did correct or if there are some other way to make batch downloading.
Can anyone help me? Thank you.