From 0fda12af2a9c2d834cb86941c6eea1a03d8d8ef5 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 31 May 2013 10:55:00 -0700 Subject: [PATCH] Minor refactoring and reformatting --- AFNetworking/AFJSONRequestOperation.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 2bc3f32..27d3b6d 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -75,15 +75,15 @@ static dispatch_queue_t json_request_operation_processing_queue() { } else { // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character // See http://stackoverflow.com/a/12843465/157142 - NSData *JSONData = [self.responseString dataUsingEncoding:NSUTF8StringEncoding]; + NSData *data = [self.responseString dataUsingEncoding:NSUTF8StringEncoding]; - if (JSONData) { - self.responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:self.JSONReadingOptions error:&error]; + if (data) { + self.responseJSON = [NSJSONSerialization JSONObjectWithData:data options:self.JSONReadingOptions error:&error]; } else { - //Could not decode response string - error = [[NSError alloc]initWithDomain:AFNetworkingErrorDomain - code:NSURLErrorCannotDecodeContentData - userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Could not decode:\n%@",self.responseString]}]; + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + [userInfo setValue:@"Operation responseData failed decoding as a UTF-8 string" forKey:NSLocalizedDescriptionKey]; + [userInfo setValue:[NSString stringWithFormat:@"Could not decode string: %@", self.responseString] forKey:NSLocalizedFailureReasonErrorKey]; + error = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; } }