小编L0r*_*rek的帖子

AFNetworking +暂停/继续下载大文件

我需要使用我的iPad应用程序下载大型.zip文件(最大800 MB).如果取消下载或应用程序在后台,我想再次恢复下载.

operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:YES];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject){

// unzip the .zip


}failure:^(AFHTTPRequestOperation *operation, NSError *error){

//Handle the error

}];


[operation setDownloadProgressBlock:^(NSInteger bytesWritten, long long totalBytesWritten,long long totalBytesExpectedToWrite) {

//update the progressView

}];

[operation setShouldExecuteAsBackgroundTaskWithExpirationHandler:^{

// What I have to do here?

}];

[operation start];
[operation waitUntilFinished];


-(void)applicationWillResignActive:(UIApplication *)application{

// What I have to do here?

}
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

resume objective-c download ipad afnetworking

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

afnetworking ×1

download ×1

ipad ×1

objective-c ×1

resume ×1