如何使用 Zlib 压缩数据,而不直接使用 zlib.dylib?
是否有一个类允许使用 Zlib 压缩数据,或者直接使用 zlib.dylib 是我唯一的可能性?
Is there a class that allows compressing data using Zlib, or is using zlib.dylib directly the only possibility I have?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
NSData+Compression 是一个易于使用的 NSData 类别实现。
用法:
NSData+Compression is an easy to use NSData category implementation.
Usage:
这对我有用:
1)基于ZLib的Objective-Zip新位置:https://github.com/gianlucabertani/Objective-Zip< /a>
Podfile:
简单示例:
2)其他基于 zlib 的库也工作得很好。 https://github.com/ZipArchive/ZipArchive
注意:有时需要添加 libz.tbd ( zlib.dylib 的新名称)到“链接二进制文件与库”
简单示例:
Here is what worked for me:
1) ZLib based Objective-Zip new location: https://github.com/gianlucabertani/Objective-Zip
Podfile:
Quick example:
2) Other zlib based library worked fine too. https://github.com/ZipArchive/ZipArchive
note: sometimes it's needed to add libz.tbd (new name of zlib.dylib) to "Link Binary With Libraries"
Quick example:
作为替代方案,还有 objective-zip,即“一个小 Cocoa/以面向对象的友好方式包装 ZLib 和 MiniZip 的 Objective-C 库。”
将文件写入“.zip”存档非常简单,只需执行以下代码即可:
该库还允许读取“.zip”文件的内容,并枚举它包含的文件。
列出“.zip”文件的内容是通过类似于以下代码的代码完成的。
As alternative, there is also objective-zip, which is, "a small Cocoa/Objective-C library that wraps ZLib and MiniZip in an object-oriented friendly way."
Writing a file into a ".zip" archive is simple as executing the following code:
The library allows also to read the content of a ".zip" file, and to enumerate the files it contains.
Listing the content of a ".zip" file is done from code similar to the following one.