zoukankan      html  css  js  c++  java
  • iOS开发中的压缩以及解压

    事实上,在iOS开发中,压缩与解压,我都是采用第三方框架SSZipArchive实现的

    gitHub地址:   https://github.com/ZipArchive/ZipArchive

    上面有详细的使用方法

    因为ZipArchive不支持ARC,所以如果你的工程开启了ARC,那么就需要对ZipArchive设置一下。在ZipArchive.mm编译选项中,增加-fno-objc-arc即可。

    最后,需要为工程链接libz.dylib动态链接库

    使用示范(压缩):

    // 获得mainBundle中所有的png的图片路径
        NSArray *pngs = [[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:nil];
        
        // zip文件路径
        NSString *caches = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
        NSString *zipFilepath = [caches stringByAppendingPathComponent:@"pngs.zip"];
        
        // 创建zip文件
        [SSZipArchive createZipFileAtPath:zipFilepath withFilesAtPaths:pngs];
    
    
     
    

     解压:

      NSString *caches = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
      NSString *filepath = [caches stringByAppendingPathComponent:@"文件名.zip"];
      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
               // 解压(文件大, 会比较耗时,所以放到子线程中解压)
              [SSZipArchive unzipFileAtPath:filepath toDestination:caches];
           });
    
  • 相关阅读:
    ng的ngModel用来处理表单操作
    ionic改tab文字和icon图片的颜色
    ionic安装遇到的一些问题
    ionic运行测试
    安卓sdk安装教程
    ionic教程
    ng 构建
    ng websocket
    ng依赖注入
    Python: 定时器(Timer)简单实现
  • 原文地址:https://www.cnblogs.com/ziyi--caolu/p/4674973.html
Copyright © 2011-2022 走看看