Last active
March 15, 2017 09:29
-
-
Save swizzlr/8478966 to your computer and use it in GitHub Desktop.
Plaintext response serializer for 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
@interface LMLPlaintextResponseSerializer : AFHTTPResponseSerializer | |
@end | |
@implementation LMLPlaintextResponseSerializer | |
- (id)responseObjectForResponse:(NSURLResponse *)response data:(NSData *)data error:(NSError *__autoreleasing *)error { | |
[super responseObjectForResponse:response data:data error:error]; //BAD SIDE EFFECTS BAD BUT NECESSARY TO CATCH 500s ETC | |
NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)([response textEncodingName] ?: @"utf-8"))); | |
return [[NSString alloc] initWithData:data encoding:encoding]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks !