Search code examples
iosasihttprequest

ASIHTTPRequest download is writing JSON error to zip


I have a method for downloading a file as file_name.zip to the documents directory. However, if I receive an error, such as 'file does not exist', the library is writing the JSON payload to file_name.zip.

How do we check for JSON error in requestFinished:?

responseString or responseData is always null.


Solution

  • You probably want to check the request.responseStatusCode and check against a 404 error. But honestly you should look into AFNetworking. ASIHTTPRequest is no longer supported and AFNetworking has success/failure blocks.