I need to zip a subdirectory of my Documents folder in an iOS app. After consulting Google and other SO posts, I’ve found ZipKit and ZipArchive as two open source projects offering this functionality. At this point, I’ve chosen to implement ZipKit, as it seems to be much more currently maintained than ZipArchive.
I’ve found examples of how to unzip archives, but haven’t been able to find an example of how to archive a directory into a .zip file. I have tried the following code, which returned a successful result status, but no zip file was actually generated.
// projectPath is /Documents/projects/myproject
ZKDataArchive *archive = [[ZKDataArchive alloc] init];
NSInteger result = [archive deflateDirectory:projectPath relativeToPath:nil usingResourceFork:NO];
I’m sure there’s something basic I’m not doing correctly, but haven’t been able to sort out what it is. In particular, I haven’t yet figured out the meaning of each parameter to deflateDirectory:.
If anyone can point me in the right direction (or has other recommendations for zipping directories on iOS) I would greatly appreciate it.
Thanks!
Success. Here’s the scoop for anyone else:
Let’s say we want to zip /Documents/myfolder
And the zip file is created!