UseObjective-C decompress the ZIP fileThe tutorial is the content to be introduced in this article.Objective-CHow to comeDecompress the ZIP file.
1. first introduce the libz. dylib framework
2. To begin.
3,Decompress the ZIP fileThe Code is as follows:
- 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,Decompress the ZIP fileThe Code is as follows:
- 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];
Summary: UseObjective-C decompress the ZIP fileThe content of this tutorial has been introduced. I hope this article will help you!