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

前端 未结 4 1607
遇见更好的自我
遇见更好的自我 2020-12-01 22:11

I have a web-service running on Windows Azure which returns JSON that I consume in my iPhone app.

Unfortunately, Windows Azure doesn\'t seem to support the compressi

4条回答
  •  生来不讨喜
    2020-12-01 22:47

    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.

提交回复
热议问题