C.Johns
C.Johns

Reputation: 10245

ASIHTTPRequest zlib decompression

I'm trying to decompress some data that Im getting which is being compressed with zlib but Im getting a warning in my code that I'm not sure how to correct.

- (void)requestFinished:(ASIHTTPRequest *)request
{

    responseData = [request responseData]; //Pass compressed data from server over to NSData variable might use to check size
    NSData *uncompressedResponseData = [[NSData alloc] init];
    uncompressedResponseData = [[request responseData] zlibInflate];  //error here

    //Is this where I have to think about decompression? or do I pass this data out to another method?
}

The error reads as

Receiver type 'NSData' for instance message dose not declare a method with selector 'zlibInflate'

Any help would be appreciated

Upvotes: 0

Views: 326

Answers (1)

occulus
occulus

Reputation: 17014

The problem is that you're calling a method, zlibInflate, on an object which doesn't support that method: NSData represents some arbitrary data, and doesn't know anything about uncompressing data.

Are you sure you want to be attempting to deflate the data you get back anyway? Doesn't ASIHTTPRequest handle the inflating for you (if the server returned gzip'd data)?

What happens if you just treat the NSData you get back as if it's already been inflated?

Also see the changelog, in particular the part titled "On-the-fly gzip decompression".

Upvotes: 1

Related Questions