ios 解壓下載數據包(zip)

須要用到一個名叫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];
相關文章
相關標籤/搜索