I have this code in case of failure:
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON)
and I want to log the string that is returned. Out of which variable should I do that and how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So typically you want to print the error, this will print any thing that your server is reporting as an error. Failure messages are triggered when it received the wrong type it was expecting (plaintext instead of application/json) or if the status code is >400 like (404, 401) stuff like that.
If you’re doing error checking you should either set the statuscode in the response header and then compare it to
response.statusCodeor most likely when you are returning data you should error check in the success block.If you absolutely need to access the responseString from the response you can use
operation.responseStringwhere operation is the AF Request Operation.update
here is an example from @mattt at https://github.com/AFNetworking/AFNetworking/issues/137: