In this tutorial, I am going to demonstrate how you can zip and unzip files from within your iOS applications. We will be using a third party library called ZipArchive to achieve this. While there are a couple solutions out there to zip and unzip files, I feel that the ZipArchive library was the fastest and easiest way to get up and running.
Lately I have seen zip, rar, and 7-zip compression related topics being searched for on this site. Since those searches are coming up empty thought it would be a good idea to post about some of the available libraries, and examples related to these common desktop compression methods.
Here are some open source alternatives for handling these common compression types:
– This is an Objective-C .zip compression library from i that can handle the standard PKZip format. You can perform all the expected zip functions, and interrupt the compression cleanly so you can run your unzipping in a separate thread, and cancel if neccessary without any issues. An example project is included – be sure to check the documentation wiki for within your apps.
– From this is an example that includes the C++ Portable Unrar project and provides a working demonstration showing how view the contents of a rar file, and extract files using Objective-C.
- This is a multi-language SDK for handling 7-zip files. Mo Dejong has created an example demonstrating how to use the LZMA SDK to decompress 7-zip libraries on iOS devices. You can find the example on his website .
If you are looking for info on how to handle gzip compression theis from that were mentioned in an will allow you to handle gzip compression easily. No library downloads required as only Zlib is used.
While I know there are other alternatives (especially for .Zip) these examples and frameworks should get you started for handling these compression types.
Recent Comments