Is there a compression API available for use on the iPhone? We're building some RESTful web services for our iPhone app to talk to, but we want to compress at least some of the conversations for efficiency.
I don't care what the format (ZIP, LHA, whatever) is, and it does not need to be secure.
Some respondents have pointed out that the server can compress its output, and the iPhone can consume that. The scenario we have is exactly the reverse. We'll be POSTing compressed content to the web service. We're not concerned with compression going the other way.
I believe zlib is available on the phone.
If you have only compressed data and know uncompressed size you can use:
zlib and bzip2 are available. And you can always add others, as long as they'll (generally) compile under OS X.
bzip2 is a better choice for smallest file sizes, but requires much more CPU power to compress and decompress.
Also, since you're talking to a web service, you may not have to do much. NSURLRequest accepts gzip encoding transparently in server responses.
NSURL says it supports the gzip encoding so you shouldn't have to do anything more than have your RESTful web service return gzip encoded content when appropriate. All the decoding will be done under the covers.
trust me the best choice is to use ZipArchive see: How to decompress an AES-256 encrypted Zip file?
ready for help if needed.
If you store the data for the conversations in an NSData object, the folks at the CocoaDev wiki have posted an NSData category that adds gzip and zlib compression / decompression as simple methods. These have worked well for me in my iPhone application.
As the above link has gone dead while the CocoaDev wiki is being moved to a new host, I've reproduced this category in its entirety below.
Interface:
Implementation: