Now I know that xCode automaticly does the GZip decrompession for you within:
NSData *data = [NSData dataWithContentsOfURL:URL];
And it does work if I point to a Gzip file on my server. But since my content is dynamic, I have a PHP script that rather then create a gzip file like so:
$zp = gzopen($file, "r");
$data = gzread($zp, $filesize);
gzclose($zp);
I encode my own data with:
echo gzencode($data, 9);
With this I add the following headers:
header("Content-Type: application/x-gzip");
header("Content-Encoding: gzip");
header("Accepts-Encoding: gzip");
When I browse to the URL, my browser wants to download the file automatically and I am able to unzip it on my Mac and view it's content. However when I try to read it through xCode it won't work.
NSData *data = [NSData dataWithContentsOfURL:URL];
NSString *content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog (content); //returns only data when pointed directly to a Gzip file
Am I forgetting something?