Skip to content

Commit 9667b21

Browse files
committed
Refactoring conditional in responseJSON to avoid unnecessary nil-ing of responseJSON
1 parent f388740 commit 9667b21

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

AFNetworking/AFJSONRequestOperation.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ - (id)responseJSON {
7070

7171
// 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.
7272
// See https://github.com/rails/rails/issues/1742
73-
if ([self.responseData length] == 0 || !self.responseString || [self.responseString isEqualToString:@" "]) {
74-
self.responseJSON = nil;
75-
} else {
73+
if ([self.responseData length] > 0 && self.responseString && ![self.responseString isEqualToString:@" "]) {
7674
// Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character
7775
// See http://stackoverflow.com/a/12843465/157142
7876
NSData *data = [self.responseString dataUsingEncoding:NSUTF8StringEncoding];

0 commit comments

Comments
 (0)