AFNetworking 3.0 downtask。下载内存中的数据总会导致内存爆炸

时间:2016-01-15 03:08:01

标签: ios afnetworking-3

< p> AFNetworking 3.0 downtask。下载内存中的数据将始终导致内存爆炸。< / p> < pre>< code> NSURLSessionConfiguration * configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; AFURLSessionManager * manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; NSURL * URL = [NSURL URLWithString:@" http://dlsw.baidu.com/sw-search-sp/soft/9d/25765/sogou_mac_32c_V3.2.0.1437101586.dmg"]; NSURLRequest * request = [NSURLRequest requestWithURL:URL]; _downloadTask = [manager downloadTaskWithRequest:请求进度:^(NSProgress * _Nonnull downloadProgress){     dispatch_async(dispatch_get_main_queue(),^ {         [progressview setProgress:downloadProgress.fractionCompleted animated:YES];         dispatch_after(dispatch_time(DISPATCH_TIME_NOW,(int64_t)(0.3 * NSEC_PER_SEC)),dispatch_get_main_queue(),^ {             str = [NSString stringWithFormat:@"%。2f&#34 ;,downloadProgress.fractionCompleted * 100];             lab.text = STR;         });     }); } destination:^ NSURL * _Nonnull(NSURL * _Nonnull targetPath,NSURLResponse * _Nonnull response){     NSURL * documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask properForURL:targetPath create:NO er​​ror:nil];     return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; } completionHandler:^(NSURLResponse * _Nonnull响应,NSURL * _Nullable filePath,NSError * _Nullable错误){     NSLog(@"文件下载到:%@",filePath); }]; < /代码>< /预> < p>< img src =" https://i.stack.imgur.com/uGeFg.jpg" ALT ="一个">< / p为H. < p>< img src =" https://i.stack.imgur.com/FprKL.jpg" ALT ="三">< / p为H.

0 个答案:

没有答案