Ziparchive is based on the open source code "Minizip" zip compression and decompression of the Objective-c class, very simple to use
Method: Download Ziparchive.zip from http://code.google.com/p/ziparchive/, add code to project after decompression, and adding zlib library to Project
How to use:
1. Compression: Ziparchive can compress multiple files, only need to addfiletozip the file one by one.
ziparchive* zip = [[Ziparchive alloc] init]; Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES); NSString *documentpath = ([Paths count] > 0)? [Paths objectatindex:0]: nil; nsstring* l_zipfile = [documentpath stringbyappendingstring:@ "/test.zip"]; nsstring* image1 = [documentpath stringbyappendingstring:@ "/image1.jpg"]; nsstring* image2 = [documentpath stringbyappendingstring:@ "/image2.jpg"]; BOOL ret = [zip Createzipfile2:l_zipfile];ret = [zip addfiletozip:image1 newname:@ "image1.jpg"];ret = [zip addfiletozip:i Mage2 newname:@ "Image2.jpg"];if (![ Zip CloseZipFile2]) { l_zipfile = @ ""; } [Zip release];
2. Unzip:
ziparchive* zip = [[Ziparchive alloc] init]; Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES); NSString *documentpath = ([Paths count] > 0)? [Paths objectatindex:0]: nil; nsstring* l_zipfile = [documentpath stringbyappendingstring:@ "/test.zip"]; nsstring* Unzipto = [documentpath stringbyappendingstring:@ "/test"]; if ([Zip Unzipopenfile:l_zipfile]) { BOOL ret = [Zip Unzipfileto:unzipto overwrite:yes]; if (No==ret) { } [zip Unzipclosefile];} [Zip release];
From:http://www.cnblogs.com/foxmin/archive/2012/09/18/2690359.html
"Go" iOS development compression and decompression files