如何使用Objective C创建一个zip文件? [英] How can I create a zip file by using Objective C?

查看:119
本文介绍了如何使用Objective C创建一个zip文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个iOS应用程序,并试图压缩在应用程序中创建的文件,是否有任何内置函数能够做到这一点?

I am developing an iOS application, and trying to zip the file I have created in the application, is there any built in function able to do this?

推荐答案

正如亚历克斯指出,我回答了这个问题通过指出Cocoadev wiki用户提供的 NSData类别。该类别包括在NSData实例中处理压缩和gzip压缩数据的方法(可以从Zip文件读取或写入)。这应该是所有你需要实现文件拉链你描述,只要你可以将您的文件数据馈送到NSData实例。

As Alex pointed out, I responded to this question by pointing out the NSData category contributed by users of the Cocoadev wiki. That category includes methods for dealing with zipped and gzipped data in an NSData instance (that could be read from a Zip file or written to one). This should be all you need to implement the file zipping you describe, as long as you can feed your file data into an NSData instance.

有关此类别的示例操作,请参阅我的iPhone应用程序的源代码,分子。我只使用该方法从gzipped文件中提取数据(在SLSMolecule + PDB.m),但你应该能够从中获得基本概念。

For an example of this category in action, please see the source code for my iPhone application, Molecules. I only use the method to extract data from a gzipped file (in SLSMolecule+PDB.m), but you should be able to get the basic concepts from that.

这篇关于如何使用Objective C创建一个zip文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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