Last active
September 11, 2018 09:02
-
-
Save iandundas/c952249d343a75350972 to your computer and use it in GitHub Desktop.
How to get response body in an AFNetworking failure block #AFNetworking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I can never, ever remember how to do this, so here's how: | |
failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
NSData *data= error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; | |
NSString *failureResponse = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; | |
NSLog(@"Failure response: %@", failureResponse); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can also do it like this, if server returns error in plaintext: