From 7d465da4a303e567d8fc8c1ab9177239ab8b96f9 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 9 Nov 2011 10:12:40 -0600 Subject: [PATCH] Throw an exception if no JSON parsing or generation functionality is available in AFJSONEncode/AFJSONDecode --- AFNetworking/AFJSONUtilities.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AFNetworking/AFJSONUtilities.h b/AFNetworking/AFJSONUtilities.h index 95dc938..5064e37 100644 --- a/AFNetworking/AFJSONUtilities.h +++ b/AFNetworking/AFJSONUtilities.h @@ -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;