Compress/Decompress NSString in objective-c (iphone) using GZIP or deflate

Solution 1:

After all this time, I finally found a solution to this problem!

None of the answers above helped me, as promising as they all looked. In the end, I was able to compress the string on the server with gzip using the chilkat framework for .net ... and then decompress it on the iphone using the chilkat framework for iOS (not yet released, but available if you email the guy directly).

The chilkat framework made this super easy to do so big thumbs up to the developer!

Solution 2:

Your "compressed" string is not raw GZIP'd data, it's in some encoding that allows those bytes to be stored in a string-- looks like base-64 or something like it. To get an NSData out of this, you'll need to decode it into the NSData.

If it's really base-64, check out this blog post an accompanying code: http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html which will do what you want.

Once you have an NSData object, the ASIHTTPRequest method will probably do as you like.