Minor refactoring and reformatting
This commit is contained in:
parent
f8d090f159
commit
0fda12af2a
1 changed files with 7 additions and 7 deletions
|
|
@ -75,15 +75,15 @@ static dispatch_queue_t json_request_operation_processing_queue() {
|
||||||
} else {
|
} else {
|
||||||
// Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character
|
// 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
|
// See http://stackoverflow.com/a/12843465/157142
|
||||||
NSData *JSONData = [self.responseString dataUsingEncoding:NSUTF8StringEncoding];
|
NSData *data = [self.responseString dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
if (JSONData) {
|
if (data) {
|
||||||
self.responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:self.JSONReadingOptions error:&error];
|
self.responseJSON = [NSJSONSerialization JSONObjectWithData:data options:self.JSONReadingOptions error:&error];
|
||||||
} else {
|
} else {
|
||||||
//Could not decode response string
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||||
error = [[NSError alloc]initWithDomain:AFNetworkingErrorDomain
|
[userInfo setValue:@"Operation responseData failed decoding as a UTF-8 string" forKey:NSLocalizedDescriptionKey];
|
||||||
code:NSURLErrorCannotDecodeContentData
|
[userInfo setValue:[NSString stringWithFormat:@"Could not decode string: %@", self.responseString] forKey:NSLocalizedFailureReasonErrorKey];
|
||||||
userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Could not decode:\n%@",self.responseString]}];
|
error = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue