须要用到一个名叫ZipArchive的开源工具 工具
须要使用前将一些有retain,release的语句删掉 google
下载地址:http://code.google.com/p/ziparchive/wiki/PageName code
用法: ip
1)将开源文件引入工程,并#import "ZipArchive.h" get
2)解压 it
ZipArchive *za = [[ZipArchive alloc] init]; if ([za UnzipOpenFile:zipPath]) { BOOL ret = [za UnzipFileTo:unzipPath overWrite:YES]; if (NO == ret) { NSLog(@"unzip file failure....."); } NSLog(@"zip fininshed..."); [za UnzipCloseFile]; }3) 建立并压缩文件
BOOL ret = [zip CreateZipFile2:l_zipfile]; // OR BOOL ret = [zip CreateZipFile2:l_zipfile Password:@"your password"]; // //if the Password is empty, will get the same effect as [zip CreateZipFile2:l_zipfile]; ret = [zip addFileToZip:l_photo newname:@"photo.jpg"]; if( ![zip CloseZipFile2] ) { // error handler here } [zip release];