使用Objective-C解压缩ZIP文件教程
来源:互联网 发布:led显示屏软件密码 编辑:程序博客网 时间:2024/06/05 09:24
转自:http://mobile.51cto.com/iphone-283401.htm
使用Objective-C解压缩ZIP文件教程是本文要介绍的内容,主要来学习的是在Objective-C如何来解压缩ZIP文件,来看本文详细内容。
1、首先引入libz.dylib框架
2、到http://code.google.com/p/ziparchive/downloads/list下载所需要的第三方文件,并将其导入到项目中。
3、解压缩ZIP文件代码如下:
- ZipArchive* zip = [[ZipArchive alloc] init];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *dcoumentpath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
- NSString* l_zipfile = [dcoumentpath stringByAppendingString:@"/test.zip"] ;
- NSString* image1 = [dcoumentpath stringByAppendingString:@"/2.png"] ;
- NSString* image2 = [dcoumentpath stringByAppendingString:@"/3.png"] ;
- BOOL ret = [zip CreateZipFile2:l_zipfile];
- ret = [zip addFileToZip:image1 newname:@"2.png"];
- ret = [zip addFileToZip:image2 newname:@"3.png"];
- if( ![zip CloseZipFile2] )
- {
- l_zipfile = @"";
- }
- [zip release];
4、解压缩ZIP文件代码如下:
- ZipArchive* zip = [[ZipArchive alloc] init];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *dcoumentpath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
- NSString* l_zipfile = [dcoumentpath stringByAppendingString:@"/test.zip"] ;
- NSString* unzipto = [dcoumentpath stringByAppendingString:@"/test"] ;
- if( [zip UnzipOpenFile:l_zipfile] ) {
- BOOL ret = [zip UnzipFileTo:unzipto overWrite:YES];
- if( NO==ret ) { }
- [zip UnzipCloseFile];
- }
- [zip release];
小结:使用Objective-C解压缩ZIP文件教程的内容介绍完了,希望通过本文的学习能对你有所帮助!
- 使用Objective-C解压缩ZIP文件教程
- 使用Objective-C解压缩ZIP文件教程
- 使用Objective-C解压缩ZIP文件教程
- 使用truezip解压缩zip文件
- 使用c#解压缩zip文件
- 【c#】SharpZipLib使用,解压缩zip文件至指定文件夹内(包含文件夹解压缩)
- 使用Objective-Zip解压Zip文件
- 使用ZLib 压缩/解压缩 zip文件
- 心得 ~ 使用 zlib库 解压缩 zip文件
- PHP解压缩zip文件,使用类ZipArchiv
- qt5.4.0使用quazip解压缩zip文件
- java 解压缩zip文件
- linux 解压缩zip文件
- java 解压缩zip文件
- PHP解压缩zip文件
- zip文件压缩解压缩
- Linux 解压缩Zip文件
- java解压缩zip文件
- PHP快速删除注释
- 马化腾致信合作伙伴:灰度法则的七个维度
- Enumerate the Triangles&&http://cdn.ac.nbutoj.com/Contest/view/id/14/problem/E.xhtml
- Open Session in View
- linux find查找命令
- 使用Objective-C解压缩ZIP文件教程
- 企业架构-分析的核心思路
- arm芯片中的浮点运算(二)
- 浅析代理模式
- EclipsePHP Studio--PHP的IDE开发软件
- 给ubuntu下虚拟机virtualbox中的ubuntu安装增强功能
- C语言全局变量多文件使用
- 递归的例子
- WampServer 5 集成环境 Ver 2.0c