如何在不使用任何外部库的情况下压缩文件? [英] How to compress a file without using any external libraries?

查看:32
本文介绍了如何在不使用任何外部库的情况下压缩文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够在 iPhone/iPad 应用程序中压缩文件.我知道有一些库可以解决这个问题并且很容易集成到应用程序中,但我想知道是否已经在 Cocoa 中实现了一些东西.如果我不需要在我的项目中集成外部库,这将对我有很大帮助.

I need to be able to compress file in an iPhone/iPad application. I know there are a few libraries out there that have this problem solved and are easy to integrate in an application, but I was wondering if there is something already implemented in Cocoa. It would help me a lot if I did not need to integrate external libraries in my project.

推荐答案

你的意思是在 iOS/Objective-c 中吗?如果是这样,您确实知道您使用的大多数对象是外部库",即 Foundation 框架?

Do you mean something in iOS / objective-c ? If so, you do know that most objects you are using is an 'external library' i.e. the Foundation framework?

每个 iPhone 都附带 libz,它是用于压缩/解压缩的库.您只需像包含任何其他框架一样包含它即可.

There is, shipped with every iPhone, libz which is the library for zipping / unzipping. You just include it as if it were any other framework.

但是,您第一次使用它作为一个没有错误的现有库的可能性很小,该库已经被数百名其他开发人员测试了多年.

However, the chances that you will, first time, use it as bug free as an existing library that's been tested for years by hundreds of other developers is slim.

就我个人而言,我会很容易地选择添加一个库而不是为这样的事情编写自己的库 - 以前已经完成了,您只是在浪费时间重新编写它.尝试 ZipArchive 用于单行解压缩文件等.只需复制源代码进入您的应用程序并按 build :)

Personally, I would easily choose adding a library over writing my own for something like this - it's been done before, you're just wasting time re-writing it. Try ZipArchive for a one-liner to unzip files etc. Just copy the source code into your app and press build :)

这篇关于如何在不使用任何外部库的情况下压缩文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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