If you're searching Google for a solution to zipping and unzipping files in your app then you're likely to encounter ZipArchive first of all. However, there is a simplified version called SSZipArchive that won't throw ARC-related warnings at you when you try and run it.
- To enable the use of SSZipArchive, you first download the files from GitHub.
- Add the files from the SSZipArchive folder (i.e. SSZipArchive.m, SSZipArchive.h and the whole of the minizip folder) to your project
- Next click on the blue project file in Xcode and go to the Library and Frameworks section
- Add the libz.dylib library to your app (it is always present in Xcode, you don't need to download anything extra)
- Finally, wherever you use the SSZipArchive class remember to import the header file
EPUB WarningIf you are working with EPUB files in Xcode and want to unzip them, then dragging and dropping them into your project and doing this sort of thing:
NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"MyBook" withExtension:@"epub"];
will not allow you to build a path or url to the file. Unlike the zip file where you can do this, I've found that EPUB files work best if they are situated in the Documents or Library directory, and have a path built to them using the NSFileManager class.
What to do about EPUBsThe above will mean you can't experiment with EPUBs quite so easily as zip files, but instead will likely need to add the "Open In" file handling to your app.
In order to register the EPUB UTI, you need to know that the document Type is as follows:
and for more information on "Open In" and registering UTIs for your app, see here.
NSFileManager class (Apple, Developer)
What is the uniform type identifier for ePub files? (StackOverflow)