Search code examples
iphoneioscocoa-touchunzipios-frameworks

Unzip using libz.dylib


I have read that unzip can be done using libz.dylib library. But I am not able to find out how to do it. I am using ZipArchive to extract the files now. But still I just want to use the default framework provided by apple. Can we can do unzip operation using libz.dylib ? or is there any problem ?


Solution

  • See Below Code

    1) Download ZipArchive from Link for ZipArchive API

    2) Drag into project.

    3) Add to project existing framework libz.1.2.3.dylib (last version).

    Import #import "ZipArchive.h" header in your ViewController

     ZipArchive *za = [[ZipArchive alloc] init];
        if ([za UnzipOpenFile: filePathToUnzip]) {
                   BOOL ret = [za UnzipFileTo:filePathtoBePlacedAfterUnzip overWrite: YES];
        if(ret)
     //unzipSuceesfully.
    
     else
     //Failed to Unzip.
    
                 [za UnzipCloseFile];
       }
    [za release];