From 9667b21891cabe0a6f1a760c9de1d7ea6f1c7cbf Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 31 May 2013 11:19:21 -0700 Subject: [PATCH] Refactoring conditional in responseJSON to avoid unnecessary nil-ing of responseJSON --- AFNetworking/AFJSONRequestOperation.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 1f0a28f..77ed574 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -70,9 +70,7 @@ static dispatch_queue_t json_request_operation_processing_queue() { // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. // See https://github.com/rails/rails/issues/1742 - if ([self.responseData length] == 0 || !self.responseString || [self.responseString isEqualToString:@" "]) { - self.responseJSON = nil; - } else { + if ([self.responseData length] > 0 && self.responseString && ![self.responseString isEqualToString:@" "]) { // 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 *data = [self.responseString dataUsingEncoding:NSUTF8StringEncoding];