使用Swift解压缩zip文件 [英] Decompress a zip file with Swift

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

问题描述

我用Swift制作了一个游戏,但是我需要在我的网站上下载.zip文件,并使用游戏中的内容(图像). 实际上,我下载了.zip文件并将其存储在文档中,并且需要将文件解压缩到相同的documents文件夹中.

I made a game in Swift but I need to download .zip files on my website, and use the content (images) in game. Actually, I download the .zip file and store it in documents, and I need to unzip the file into the same documents folder.

我尝试了marmelroy的Zip,iOS 9压缩模块和tidwall的DeflateSwift,但是这些都不起作用.如果它与iOS 8兼容可能会很好.

I tried marmelroy's Zip, iOS 9 Compression module and tidwall's DeflateSwift but none of these worked. It could be good if it was compatible with iOS 8.

推荐答案

我将它与SSZipArchive和桥接头一起使用:

I got it work with SSZipArchive and a bridging header:

  1. 拖动&将SSZipArchive目录放到您的项目中
  2. 使用 import"SSZipArchive.h"
  3. 行创建一个{PROJECT-MODULE-NAME} -Bridging-Header.h文件
  4. 在构建设置"中,将桥接标头拖到Swift编译器-代码生成-> Objective-C桥接标头中.
  5. 在您的Swift代码中使用SSZipArchive.
  1. Drag & drop the SSZipArchive directory in your project
  2. Create a {PROJECT-MODULE-NAME}-Bridging-Header.h file with the line import "SSZipArchive.h"
  3. In Build Settings, drag the bridging header in Swift Compiler - Code generation -> Objective-C Bridging Header.
  4. Use SSZipArchive in your Swift code.

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

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