转载自: http://blog.sina.com.cn/s/blog_833996210100udkl.html
从http://code.google.com/p/ziparchive/ 上下载ZipArchive.zip,解压后将代码加入工程中,把zlib库添加到工程中
压缩 ZipArchive* zip = [[ZipArchive alloc] init]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentPath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; NSString * zipFile = [dcoumentpath stringByAppendingString:@"/images.zip"] ; NSString *image1 = [dcoumentpath stringByAppendingString:@"/犬夜叉.jpg"] ; NSString *image2 = [dcoumentpath stringByAppendingString:@"/杀生丸.jpg"] ; BOOL result = [zip CreateZipFile2:zipFile]; result = [zip addFileToZip:image1 newname:@"犬夜叉.jpg"]; result = [zip addFileToZip:image2 newname:@"杀生丸.jpg"]; if( ![zip CloseZipFile2] ){ zipFile = @""; } [zip release]; 解压缩 ZipArchive* zip = [[ZipArchive alloc] init]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentPath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; NSString* zipFile = [dcoumentpath stringByAppendingString:@"/images.zip"] ; NSString* unZipTo = [dcoumentpath stringByAppendingString:@"/images"] ; if( [zip UnzipOpenFile:zipFile] ){ BOOL result = [zip UnzipFileTo:unZipTo overWrite:YES]; if( NO==result ){ //添加代码 } [zip UnzipCloseFile]; } [zip release]; 参考了一下网上的代码,请大家多多指教 相关资源:iphone文件解压缩zip-gzip