Created
July 1, 2013 20:46
-
-
Save isoiphone/5904478 to your computer and use it in GitHub Desktop.
Helpful debugging snippet for AFNetworking
This file contains 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
#ifdef DEBUG | |
[[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidStartNotification | |
object:nil | |
queue:nil | |
usingBlock:^(NSNotification *note) { | |
NSURLRequest* req = [[note object] request]; | |
dbgLog(@"REQUEST: %@ %@", [req HTTPMethod], [req URL]); | |
}]; | |
[[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification | |
object:nil | |
queue:nil | |
usingBlock:^(NSNotification *note) { | |
AFHTTPRequestOperation* afop = [note object]; | |
NSURLRequest* req = [afop request]; | |
dbgLog(@"RESPONSE: %@ %@ (%d) >>\n%@\n<<", [req HTTPMethod], [req URL], [[afop response] statusCode], [afop responseString]); | |
}]; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dbgLog() is just a macro that expands to NSLog() in debug builds (and empty in release builds)