我需要使用我的 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?
}
谢谢你的帮助。