How to get the response data out of the NSHTTPURLResponse in the callback of AFJSONRequestOperation?

Todd Hopkinson picture Todd Hopkinson · May 17, 2012 · Viewed 30.3k times · Source

I have a situation where I need to access the raw response data for an AFJSONRequestOperation, from within the callback block which includes only NSHTTPURLResponse. I am able to get the statusCode from the NSHTTPURLResponse, but don't see any way to get to the raw data. Is there a good way that anyone knows of to access this from the failure callback block of this operation?

Answer

mattt picture mattt · May 22, 2012

NSHTTPURLResponse only contains HTTP header information; no body data. So no, this would be impossible. If you have any control over this code, have the block or method pass the operation itself and get responseData or responseJSON.