- Fix Respose Error grab data

This commit is contained in:
giuseppenuc committed 2016-02-08 14:52:32 +01:00
1 parent 7a2474ea92
commit 85548a7209
9 files changed
+99 -26

No files matched your search

@@ -0,0 +1,15 @@
//
// AFJSONResponseSerializerWithData.h
// Pods
//
// Created by Giuseppe Nucifora on 08/02/16.
//
//
#import <AFNetworking/AFNetworking.h>
static NSString * const JSONResponseSerializerWithDataKey = @"JSONResponseSerializerWithDataKey";
@interface AFJSONResponseSerializerWithData : AFJSONResponseSerializer
@end
@@ -0,0 +1,31 @@
//
// AFJSONResponseSerializerWithData.m
// Pods
//
// Created by Giuseppe Nucifora on 08/02/16.
//
//
#import "AFJSONResponseSerializerWithData.h"
@implementation AFJSONResponseSerializerWithData
- (id)responseObjectForResponse:(NSURLResponse *)response
data:(NSData *)data
error:(NSError *__autoreleasing *)error
{
id JSONObject = [super responseObjectForResponse:response data:data error:error];
NSHTTPURLResponse *currentResponse = (NSHTTPURLResponse*)response;
if (*error != nil) {
NSData *errorData = [[(*error).userInfo mutableCopy] objectForKey:AFNetworkingOperationFailingURLResponseDataErrorKey];
NSMutableDictionary *userInfo = [NSJSONSerialization JSONObjectWithData: errorData options:kNilOptions error:nil];;
NSError *newError = [NSError errorWithDomain:(*error).domain code:currentResponse.statusCode userInfo:userInfo];
(*error) = newError;
}
return (JSONObject);
}
@end