Skip to content

Commit

Permalink
Throw an exception if no JSON parsing or generation functionality is …
Browse files Browse the repository at this point in the history
…available in AFJSONEncode/AFJSONDecode
  • Loading branch information
mattt committed Nov 9, 2011
1 parent 03bc87d commit 7d465da
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions AFNetworking/AFJSONUtilities.h
Expand Up @@ -82,6 +82,9 @@ static NSData * AFJSONEncode(id object, NSError **error) {

[invocation invoke];
[invocation getReturnValue:&data];
} else {
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedString(@"Please either target a platform that supports NSJSONSerialization or add one of the following libraries to your project: JSONKit, SBJSON, or YAJL", nil) forKey:NSLocalizedRecoverySuggestionErrorKey];
[NSException exceptionWithName:NSInternalInconsistencyException reason:NSLocalizedString(@"No JSON generation functionality available", nil) userInfo:userInfo];
}

return data;
Expand Down Expand Up @@ -138,6 +141,9 @@ static id AFJSONDecode(NSData *data, NSError **error) {

[invocation invoke];
[invocation getReturnValue:&JSON];
} else {
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedString(@"Please either target a platform that supports NSJSONSerialization or add one of the following libraries to your project: JSONKit, SBJSON, or YAJL", nil) forKey:NSLocalizedRecoverySuggestionErrorKey];
[NSException exceptionWithName:NSInternalInconsistencyException reason:NSLocalizedString(@"No JSON parsing functionality available", nil) userInfo:userInfo];
}

return JSON;
Expand Down

0 comments on commit 7d465da

Please sign in to comment.