Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

ios - Unzip files in 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];
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Swift 2 (Update):

So it works for me without Errors:

  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)

    #import "SSZipArchive.h"

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

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

  5. Ready to zip/unzip


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...