在swift中解压缩文件 [英] Unzip files in swift

查看:920
本文介绍了在swift中解压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在swift中解压缩文件?在Objective-C中,我使用了SSZipArchive,我喜欢它。如下面的代码所示。我怀疑如果我决定保留SSZipArchive,我必须将Objective-C文件桥接到我的Swift文件。是否有任何更新的第三方,或更好的Apple文档在Swift中解压缩文件?

How to go about unzipping a file in swift? In Objective-C, I used SSZipArchive and I loved it. As seen in the code below. I suspect if I decide to keep SSZipArchive, I will have to bridge an Objective-C file to my Swift file. Is there any updated third-party, or better yet Apple-Documentation to unzip a file in Swift?

NSString *zipPath = [self.globalFileStrucure stringByAppendingPathComponent:@"zipfile.zip"];

[data writeToFile:zipPath options:0 error:&error];

BOOL unZipped = 0;

unZipped = [SSZipArchive unzipFileAtPath:zipPath toDestination:self.globalFileStrucure];


推荐答案

Swift 2(更新):

所以它适用于没有错误的我:

So it works for me without Errors:


  1. 下载/克隆这里的图书馆: ssziparchive

  2. 复制将项目SSZipArchive拖放到项目中(拖放)并选择创建组

  3. 将库包含到Project Swift-ObjC Bridge(xxxx-Bridge-Header.h)中)

  1. download/clone the Library here: ssziparchive
  2. copy the Directory "SSZipArchive" to your Project (Drag&Drop) and select 'Create groups'
  3. include the library to your Project Swift-ObjC Bridge (xxxx-Bridge-Header.h)

#importSSZipArchive.h

#import "SSZipArchive.h"

链接库libz.tbd - iOS的一部分

link the Library "libz.tbd" - Part of iOS

(项目 - >构建阶段 - >链接二进制文件库 - > +)

(Project -> Build Phases -> Link Binary With Libraries -> +)

准备拉链/解压缩

这篇关于在swift中解压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆