Created
August 1, 2012 01:57
-
-
Save sspencer/3222686 to your computer and use it in GitHub Desktop.
Override MKNetworkOperation so 4xx response body available in the error handler
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
// Register your NetworkOperation class after creating your network engine | |
// someEngine = [[SomeEngine alloc] initWithHostName:SOME_API customHeaderFields:nil]; | |
// [someEngine registerOperationSubclass:[SomeNetworkOperation class]]; | |
// ------ SomeNetworkOperation.h ------ | |
#import "MKNetworkOperation.h" | |
@interface SomeNetworkOperation : MKNetworkOperation | |
@end | |
// ------ SomeNetworkOperation.m ------ | |
#import "SomeNetworkOperation.h" | |
@implementation SomeNetworkOperation | |
-(void) operationFailedWithError:(NSError*) error | |
{ | |
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:error.userInfo]; | |
[userInfo setObject:[self responseString] forKey:@"responseString"]; | |
[super operationFailedWithError:[NSError errorWithDomain:NSURLErrorDomain code:error.code userInfo:userInfo]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment