imn*_*lly 8 objective-c unzip ios swift ssziparchive
如何在swift中解压缩文件?在Objective-C中,我使用了SSZipArchive,我喜欢它.如下面的代码所示.我怀疑如果我决定保留SSZipArchive,我将不得不将Objective-C文件桥接到我的Swift文件.是否有任何更新的第三方,或更好的Apple文档在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];
Run Code Online (Sandbox Code Playgroud)
Pet*_*inz 19
Swift 2(更新):
所以它适用于没有错误的我:
将库包含到Project Swift-ObjC Bridge(xxxx-Bridge-Header.h)中
#import"SSZipArchive.h"
链接库"libz.tbd" - iOS的一部分
(项目 - >构建阶段 - >使用库链接二进制 - > +)
准备压缩/解压缩
如果您正在使用 UIKit 或 AppKit 中的任何一个,则您已经在使用 Swift-ObjC 桥接器。不用担心,只需使用您熟悉和喜爱的图书馆即可!
let zipPath = globalFileStrucure.stringByAppendingPathComponent("zipfile.zip")
data.writeToFile(zipPath, options: nil, error: &error)
let unZipped = SSZipArchive.unzipFileAtPath(zipPath, toDestination: globalFileStrucure)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14709 次 |
| 最近记录: |