如何在iOS上解压缩.zip文件? [英] How to unzip a .zip file on iOS?
问题描述
在StoreKit下载IAP内容包后,它会向我返回一个NSURL,如下所示:
After StoreKit downloads the IAP content package it returns an NSURL to me which looks like this:
file:// localhost / private /var/mobile/Applications/45EF2B3A-3CAB-5A44-4B4A-631A122A4299/Library/Caches/BA32BC55-55DD-3AA4-B4AC-C2A456622229.zip /
file://localhost/private/var/mobile/Applications/45EF2B3A-3CAB-5A44-4B4A-631A122A4299/Library/Caches/BA32BC55-55DD-3AA4-B4AC-C2A456622229.zip/
尽管我发现所有来源都声称StoreKit在下载后解压缩了内容包,但它还是通过ZIP传递给我。此ZIP可能包含内容包的文件结构。但是如何解压缩?
Despite all sources I found claiming that StoreKit unzips the content package once downloaded, it hands me over a ZIP. This ZIP probably contains the file structure of the content package. But how do I unzip this?
推荐答案
使用 SSZipArchive
您可以使用此解压缩
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *outputPath = [documentsDirectory stringByAppendingPathComponent:@"/ImagesFolder"];
NSString *zipPath = Your zip file path;
[SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:self];
希望对您有帮助。
这篇关于如何在iOS上解压缩.zip文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!