在iOS下载和解压缩文件

Huy*_*ran 27 zip objective-c unzip ios

我想下载一个zip文件,其中包含一个文件夹,里面有很多文件音频,用于我的字典发音.我使用ASIHTTPRequest下载它,我的问题是"我不知道如何解压缩该文件".我试图用SSZipArchiveZipArchive他们两个是基于minizip,但我得到的错误,当我编译代码Undefined symbols for architecture i386: "_OBJC_CLASS_$_ZipArchive", referenced from: objc-class-ref in AppDelegate.o.所以你能给我一些建议

Sri*_*aju 49

我过去曾经使用过ZipArchive.它非常轻巧,易于使用,支持密码保护,ZIP内的多个文件,以及压缩和解压缩.

基本用法是:

NSString *filepath = [[NSBundle mainBundle] pathForResource:@"ZipFileName" ofType:@"zip"];
ZipArchive *zipArchive = [[ZipArchive alloc] init];
[zipArchive UnzipOpenFile:filepath Password:@"xxxxxx"];
[zipArchive UnzipFileTo:{pathToDirectory} overWrite:YES];
[zipArchive UnzipCloseFile];
[zipArchive release];
Run Code Online (Sandbox Code Playgroud)

有关此包的更多的例子在这里

我也在一些项目中尝试过SSZipArchive.下面的行将解压缩您的zip文件.

[SSZipArchive unzipFileAtPath:path toDestination:destination];
Run Code Online (Sandbox Code Playgroud)