在iOS下载和解压缩文件 [英] download and unzip file in iOS

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

问题描述

我想下载一个zip文件,其中包含一个包含大量文件音频的文件夹,用于我在字典中的发音。我使用ASIHTTPRequest下载它,我的问题是我不知道如何解压缩该文件。我尝试使用 SSZipArchive ZipArchive 它们都基于 minizip 但是当我编译代码时出现错误架构i386的未定义符号:_ OBJC_CLASS _ $ _ ZipArchive,引自:AppDelegate.o中的objc-class-ref 。你能给我一些建议吗

I want to download a zip file contains a folder with a lot of file audios which use for my pronunciation in dictionary. I use ASIHTTPRequest to download it and my problem is "I don't know how to unzip that file". I tried to use SSZipArchive and ZipArchive both of them is based on minizip but I got error when I compile code Undefined symbols for architecture i386: "_OBJC_CLASS_$_ZipArchive", referenced from: objc-class-ref in AppDelegate.o . So could you give me some advices

推荐答案

我用过 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天全站免登陆