我正在使用AFNetworking库下载一个压缩文件夹,文件正在下载,但是当我尝试取消对该zip文件夹的压缩时,它没有打开。在Mac机器上,双击和“存档实用程序”也不会解压缩。
NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
NSLog(@"File downloaded to: %@", filePath);
[SSZipArchive unzipFileAtPath:[filePath path] toDestination: [[filePath path] stringByDeletingLastPathComponent]];
}];
最佳答案
尝试这个
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"vikas.sqlite"];
NSString *outputPath = [paths objectAtIndex:0];
[SSZipArchive unzipFileAtPath:path toDestination:outputPath delegate:self];
解压缩文件将位于输出路径上。
关于ios - 使用SSZipArchive解压缩文件而不解压缩zip文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46093018/