I am downloading images,videos with iOS 7 backgroundsession with NSURLSessionDownloadTask and it is working fine.
Now,as Apple doc suggest in background DataTask is not going to work , only Uploadtask and downloadtask are going to work.
So, with this download task i neet to get json data. so i test it with url http://www.abc.com/downloads/weather_sample/test.php?format=json so in this method
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error{
NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response;
NSDictionary *httpResponse = [response allHeaderFields];
}
i am not getting proper response , it is
<NSHTTPURLResponse: 0x894de00> { URL: http://www.abc.com/downloads/weather_sample/test.php?format=json } { status code: 200, headers {
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Length" = 734;
"Content-Type" = "application/json";
Date = "Fri, 08 Nov 2013 06:42:29 GMT";
"Keep-Alive" = "timeout=2, max=4000";
Server = "Apache/2.2.15 (CentOS)";
Vary = "Accept-Encoding";
"X-Powered-By" = "PHP/5.3.3";
} }
while i can able to store test.php file in my document directory and then able to parse in json. but for that i have to store that file in my document directory, i am not getting response directly.