From 359d51d84ab5a773f9c166dd4c0215e7988716b8 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Wed, 3 Aug 2011 21:19:49 -0700 Subject: [PATCH] Improving the check for NSJSONSerialization. We now only attempt to use NSJSONSerialization if we're compiling against a Base SDK that includes it. If we are, we still retain the NS_CLASS_AVAILABLE-based `class` check to test whether or not it's available at runtime. The fallback in both cases is to use JSONKit. --- AFNetworking/AFJSONRequestOperation.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 23a9e4e..f7c699c 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -23,6 +23,8 @@ #import "AFJSONRequestOperation.h" #import "JSONKit.h" +#include + @implementation AFJSONRequestOperation + (id)operationWithRequest:(NSURLRequest *)urlRequest @@ -61,13 +63,17 @@ } } else { id JSON = nil; - + + #if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_4_3 if ([NSJSONSerialization class]) { JSON = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; } else { JSON = [[JSONDecoder decoder] objectWithData:data error:&error]; - } - + } + #else + JSON = [[JSONDecoder decoder] objectWithData:data error:&error]; + #endif + if (error) { if (failure) { failure(error);