我们如何在目标c中解压缩文件? [英] how can we unzip a file in objective c?

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

问题描述


可能重复:

iPhone有拉链解压缩吗?





<我在我的文档目录中有一个zip文件,我想在xcode中使用目标c代码解压缩该文件,我们怎么能这样做?有可能做到这一点

i have a zip file in my document directory and i want to unzip that file using objective c code in xcode how can we do that ? is that possible to do that

谢谢
balraj

thanks balraj

推荐答案

<我在这个链接下面的堆栈溢出中找到了一个更好的答案在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];

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

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