Throw an exception if no JSON parsing or generation functionality is available in AFJSONEncode/AFJSONDecode

This commit is contained in:
Mattt Thompson 2011-11-09 10:12:40 -06:00
parent 03bc87dfd7
commit 7d465da4a3

View file

@ -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;
@ -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;