文件的压缩和解压缩

iOS文件的压缩和解压缩

iOS中对文件的解压缩处理通常都是利用第三方框架,实现解压缩,接下来就来看看吧。

// 解压文件
NSString *zipPath = @"path_to_your_zip_file";
NSString *destinationPath = @"path_to_the_folder_where_you_want_it_unzipped";
    /*
     第一个参数: 需要解压缩的文件
     第二个参数: 解压缩之后放到什么地方
     */

[Main unzipFileAtPath:zipPath    toDestination:destinationPath];

// 压缩文件
NSString *zippedPath = @"path_where_you_want_the_file_created";
NSArray *inputPaths = @[[[NSBundle mainBundle] pathForResource:@"photo1" ofType:@"jpg"],
                        [[NSBundle mainBundle] pathForResource:@"photo1" ofType:@"jpg"]];
    /*
     打包一个文件, 压缩一个文件
     第一个参数: 压缩文件的存储位置
     第二个参数: 需要压缩的文件
     */

[Main createZipFileAtPath:zippedPath
         withFilesAtPaths:inputPaths];

// Zip Directory
[Main createZipFileAtPath:zippedPath
  withContentsOfDirectory:inputPaths];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容