在iOS中解压缩下载的文件 [英] Unzipping downloaded files in iOS

查看:306
本文介绍了在iOS中解压缩下载的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASIHTTPRequest下载了一个zip文件,其中包含一个包含多个音频文件的文件夹.我试图用SSZipArchiveZipArchive都解压缩文件,这两个都是基于minizip的.

Using ASIHTTPRequest, I downloaded a zip file containing a folder with several audio files. I tried to unzip the file with SSZipArchive and ZipArchive, which are both based on minizip.

编译代码时,出现以下错误:Undefined symbols for architecture i386: "_OBJC_CLASS_$_ZipArchive", referenced from: objc-class-ref in AppDelegate.o.

When I compile the code, I get this error: Undefined symbols for architecture i386: "_OBJC_CLASS_$_ZipArchive", referenced from: objc-class-ref in AppDelegate.o.

如何在iOS中解压缩此文件?

How do I unzip this file in iOS?

推荐答案

我使用了 ZipArchive 过去取得了成功.它相当轻巧,易于使用,支持密码保护,ZIP内的多个文件以及压缩和压缩功能.解压缩.

I've used ZipArchive with success in the past. It's pretty ligthweight and simple to use, supports password protection, multiple files inside a ZIP, as well as compress & decompress.

基本用法是:

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];

有关此软件包的更多示例此处

more examples about this package here

在某些项目中,我还尝试了 SSZipArchive . 在下面的行中将解压缩您的zip文件.

I have also tried SSZipArchive in some projects. Below line would unzip your zip file.

[SSZipArchive unzipFileAtPath:path toDestination:destination];

这篇关于在iOS中解压缩下载的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆