崩溃UIProgressView + NSURLSessionDownloadTask

时间:2014-05-22 06:19:45

标签: uikit afnetworking afnetworking-2 nsurlsession

我在DownloadsViewController中开始下载文件然后关闭此控制器时会崩溃。

错误示例 - https://github.com/nullproduction/AFNetworingBug
崩溃屏幕 - http://rghost.ru/55518252/image.png

代码:

- (void)startDownload
{
    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
    AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://itunesconnect.apple.com/downloads/Documentation/AppTransferTutorial.mov?itcKey=1400686864_f4496d605f190f230687304aeeff494e"]];

    NSURLSessionDownloadTask *task = [manager downloadTaskWithRequest:request
                         progress:nil
     destination:^NSURL *(NSURL *targetPath, NSURLResponse *response)
     {
         return nil;
     }
     completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error){

     }];
    [task resume];
    [self.progressView setProgressWithDownloadProgressOfTask:task animated:YES];
}

0 个答案:

没有答案