From 2fc6d999b595cc453e265f0593bdd10f0f67556c Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Thu, 19 Jan 2012 17:25:29 -0800 Subject: [PATCH 1/4] xml_request_operation_processing_queue() is Mac-only. Wrap xml_request_operation_processing_queue() in a test for __MAC_OS_X_VERSION_MIN_REQUIRED because it is only used by a Mac-specific code block down below. This addresses an unused symbol warning when compiling with strict settings. --- AFNetworking/AFXMLRequestOperation.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AFNetworking/AFXMLRequestOperation.m b/AFNetworking/AFXMLRequestOperation.m index d01a084c66..48a67835a6 100644 --- a/AFNetworking/AFXMLRequestOperation.m +++ b/AFNetworking/AFXMLRequestOperation.m @@ -24,6 +24,7 @@ #include +#if __MAC_OS_X_VERSION_MIN_REQUIRED static dispatch_queue_t af_xml_request_operation_processing_queue; static dispatch_queue_t xml_request_operation_processing_queue() { if (af_xml_request_operation_processing_queue == NULL) { @@ -32,6 +33,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() { return af_xml_request_operation_processing_queue; } +#endif @interface AFXMLRequestOperation () @property (readwrite, nonatomic, retain) NSXMLParser *responseXMLParser; From 85599685149886d48e76816af6e028a2addc4ec4 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Thu, 19 Jan 2012 17:58:24 -0800 Subject: [PATCH 2/4] Conditionally define the _af_nsjson_* labels. These are only used when _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ is defined. Otherwise, they generate unused symbol warnings under strict compilation settings. --- AFNetworking/AFJSONUtilities.h | 54 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/AFNetworking/AFJSONUtilities.h b/AFNetworking/AFJSONUtilities.h index 5eb1addf83..6ad1adb5dc 100644 --- a/AFNetworking/AFJSONUtilities.h +++ b/AFNetworking/AFJSONUtilities.h @@ -75,19 +75,20 @@ static NSData * AFJSONEncode(id object, NSError **error) { *error = [[[NSError alloc] initWithDomain:NSStringFromClass([exception class]) code:0 userInfo:[exception userInfo]] autorelease]; } } else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { - _af_nsjson_encode: { - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]]; - invocation.target = _NSJSONSerializationClass; - invocation.selector = _NSJSONSerializationSelector; - - [invocation setArgument:&object atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - NSUInteger writeOptions = 0; - [invocation setArgument:&writeOptions atIndex:3]; - [invocation setArgument:error atIndex:4]; - - [invocation invoke]; - [invocation getReturnValue:&data]; - } +#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ + _af_nsjson_encode: +#endif + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]]; + invocation.target = _NSJSONSerializationClass; + invocation.selector = _NSJSONSerializationSelector; + + [invocation setArgument:&object atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation + NSUInteger writeOptions = 0; + [invocation setArgument:&writeOptions atIndex:3]; + [invocation setArgument:error atIndex:4]; + + [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] raise]; @@ -145,19 +146,20 @@ static id AFJSONDecode(NSData *data, NSError **error) { [invocation invoke]; [invocation getReturnValue:&JSON]; } else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { - _af_nsjson_decode: { - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]]; - invocation.target = _NSJSONSerializationClass; - invocation.selector = _NSJSONSerializationSelector; - - [invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - NSUInteger readOptions = 0; - [invocation setArgument:&readOptions atIndex:3]; - [invocation setArgument:error atIndex:4]; - - [invocation invoke]; - [invocation getReturnValue:&JSON]; - } +#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ + _af_nsjson_decode: +#endif + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]]; + invocation.target = _NSJSONSerializationClass; + invocation.selector = _NSJSONSerializationSelector; + + [invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation + NSUInteger readOptions = 0; + [invocation setArgument:&readOptions atIndex:3]; + [invocation setArgument:error atIndex:4]; + + [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] raise]; From 776b251f037f1d1873f37a343b61ead931cb1c74 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Fri, 20 Jan 2012 11:56:55 -0800 Subject: [PATCH 3/4] Move the AFJSON* functions into a source file. Previously, these functions were marked 'static' and were being included by multiple other source files. That wasn't ideal because it resulted in their implementations being duplicated in multiple link units. Worse is the fact that the previous organization generated fatal compilation errors about unused symbols when strict settings are enabled. --- AFNetworking/AFJSONUtilities.h | 147 +--------------------------- AFNetworking/AFJSONUtilities.m | 169 +++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+), 145 deletions(-) create mode 100644 AFNetworking/AFJSONUtilities.m diff --git a/AFNetworking/AFJSONUtilities.h b/AFNetworking/AFJSONUtilities.h index 6ad1adb5dc..d10737d5ec 100644 --- a/AFNetworking/AFJSONUtilities.h +++ b/AFNetworking/AFJSONUtilities.h @@ -22,148 +22,5 @@ #import -static NSData * AFJSONEncode(id object, NSError **error) { - NSData *data = nil; - - SEL _JSONKitSelector = NSSelectorFromString(@"JSONDataWithOptions:error:"); - SEL _SBJSONSelector = NSSelectorFromString(@"JSONRepresentation"); - SEL _YAJLSelector = NSSelectorFromString(@"yajl_JSONString"); - - id _NSJSONSerializationClass = NSClassFromString(@"NSJSONSerialization"); - SEL _NSJSONSerializationSelector = NSSelectorFromString(@"dataWithJSONObject:options:error:"); - -#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ - if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { - goto _af_nsjson_encode; - } -#endif - - if (_JSONKitSelector && [object respondsToSelector:_JSONKitSelector]) { - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[object methodSignatureForSelector:_JSONKitSelector]]; - invocation.target = object; - invocation.selector = _JSONKitSelector; - - NSUInteger serializeOptionFlags = 0; - [invocation setArgument:&serializeOptionFlags atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - [invocation setArgument:error atIndex:3]; - - [invocation invoke]; - [invocation getReturnValue:&data]; - } else if (_SBJSONSelector && [object respondsToSelector:_SBJSONSelector]) { - NSString *JSONString = nil; - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[object methodSignatureForSelector:_SBJSONSelector]]; - invocation.target = object; - invocation.selector = _SBJSONSelector; - - [invocation invoke]; - [invocation getReturnValue:&JSONString]; - - data = [JSONString dataUsingEncoding:NSUTF8StringEncoding]; - } else if (_YAJLSelector && [object respondsToSelector:_YAJLSelector]) { - @try { - NSString *JSONString = nil; - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[object methodSignatureForSelector:_YAJLSelector]]; - invocation.target = object; - invocation.selector = _YAJLSelector; - - [invocation invoke]; - [invocation getReturnValue:&JSONString]; - - data = [JSONString dataUsingEncoding:NSUTF8StringEncoding]; - } - @catch (NSException *exception) { - *error = [[[NSError alloc] initWithDomain:NSStringFromClass([exception class]) code:0 userInfo:[exception userInfo]] autorelease]; - } - } else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { -#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ - _af_nsjson_encode: -#endif - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]]; - invocation.target = _NSJSONSerializationClass; - invocation.selector = _NSJSONSerializationSelector; - - [invocation setArgument:&object atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - NSUInteger writeOptions = 0; - [invocation setArgument:&writeOptions atIndex:3]; - [invocation setArgument:error atIndex:4]; - - [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] raise]; - } - - return data; -} - -static id AFJSONDecode(NSData *data, NSError **error) { - id JSON = nil; - - SEL _JSONKitSelector = NSSelectorFromString(@"objectFromJSONDataWithParseOptions:error:"); - SEL _SBJSONSelector = NSSelectorFromString(@"JSONValue"); - SEL _YAJLSelector = NSSelectorFromString(@"yajl_JSONWithOptions:error:"); - - id _NSJSONSerializationClass = NSClassFromString(@"NSJSONSerialization"); - SEL _NSJSONSerializationSelector = NSSelectorFromString(@"JSONObjectWithData:options:error:"); - - -#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ - if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { - goto _af_nsjson_decode; - } -#endif - - if (_JSONKitSelector && [data respondsToSelector:_JSONKitSelector]) { - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[data methodSignatureForSelector:_JSONKitSelector]]; - invocation.target = data; - invocation.selector = _JSONKitSelector; - - NSUInteger parseOptionFlags = 0; - [invocation setArgument:&parseOptionFlags atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - [invocation setArgument:error atIndex:3]; - - [invocation invoke]; - [invocation getReturnValue:&JSON]; - } else if (_SBJSONSelector && [NSString instancesRespondToSelector:_SBJSONSelector]) { - // Create a string representation of JSON, to use SBJSON -`JSONValue` category method - NSString *string = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[string methodSignatureForSelector:_SBJSONSelector]]; - invocation.target = string; - invocation.selector = _SBJSONSelector; - - [invocation invoke]; - [invocation getReturnValue:&JSON]; - } else if (_YAJLSelector && [data respondsToSelector:_YAJLSelector]) { - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[data methodSignatureForSelector:_YAJLSelector]]; - invocation.target = data; - invocation.selector = _YAJLSelector; - - NSUInteger yajlParserOptions = 0; - [invocation setArgument:&yajlParserOptions atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - [invocation setArgument:error atIndex:3]; - - [invocation invoke]; - [invocation getReturnValue:&JSON]; - } else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { -#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ - _af_nsjson_decode: -#endif - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]]; - invocation.target = _NSJSONSerializationClass; - invocation.selector = _NSJSONSerializationSelector; - - [invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - NSUInteger readOptions = 0; - [invocation setArgument:&readOptions atIndex:3]; - [invocation setArgument:error atIndex:4]; - - [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] raise]; - } - - return JSON; -} +NSData * AFJSONEncode(id object, NSError **error); +id AFJSONDecode(NSData *data, NSError **error); diff --git a/AFNetworking/AFJSONUtilities.m b/AFNetworking/AFJSONUtilities.m new file mode 100644 index 0000000000..3b6ff25d2e --- /dev/null +++ b/AFNetworking/AFJSONUtilities.m @@ -0,0 +1,169 @@ +// AFJSONUtilities.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.com/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFJSONUtilities.h" + +NSData * AFJSONEncode(id object, NSError **error) { + NSData *data = nil; + + SEL _JSONKitSelector = NSSelectorFromString(@"JSONDataWithOptions:error:"); + SEL _SBJSONSelector = NSSelectorFromString(@"JSONRepresentation"); + SEL _YAJLSelector = NSSelectorFromString(@"yajl_JSONString"); + + id _NSJSONSerializationClass = NSClassFromString(@"NSJSONSerialization"); + SEL _NSJSONSerializationSelector = NSSelectorFromString(@"dataWithJSONObject:options:error:"); + +#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ + if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { + goto _af_nsjson_encode; + } +#endif + + if (_JSONKitSelector && [object respondsToSelector:_JSONKitSelector]) { + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[object methodSignatureForSelector:_JSONKitSelector]]; + invocation.target = object; + invocation.selector = _JSONKitSelector; + + NSUInteger serializeOptionFlags = 0; + [invocation setArgument:&serializeOptionFlags atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation + [invocation setArgument:error atIndex:3]; + + [invocation invoke]; + [invocation getReturnValue:&data]; + } else if (_SBJSONSelector && [object respondsToSelector:_SBJSONSelector]) { + NSString *JSONString = nil; + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[object methodSignatureForSelector:_SBJSONSelector]]; + invocation.target = object; + invocation.selector = _SBJSONSelector; + + [invocation invoke]; + [invocation getReturnValue:&JSONString]; + + data = [JSONString dataUsingEncoding:NSUTF8StringEncoding]; + } else if (_YAJLSelector && [object respondsToSelector:_YAJLSelector]) { + @try { + NSString *JSONString = nil; + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[object methodSignatureForSelector:_YAJLSelector]]; + invocation.target = object; + invocation.selector = _YAJLSelector; + + [invocation invoke]; + [invocation getReturnValue:&JSONString]; + + data = [JSONString dataUsingEncoding:NSUTF8StringEncoding]; + } + @catch (NSException *exception) { + *error = [[[NSError alloc] initWithDomain:NSStringFromClass([exception class]) code:0 userInfo:[exception userInfo]] autorelease]; + } + } else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { +#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ + _af_nsjson_encode: +#endif + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]]; + invocation.target = _NSJSONSerializationClass; + invocation.selector = _NSJSONSerializationSelector; + + [invocation setArgument:&object atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation + NSUInteger writeOptions = 0; + [invocation setArgument:&writeOptions atIndex:3]; + [invocation setArgument:error atIndex:4]; + + [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] raise]; + } + + return data; +} + +id AFJSONDecode(NSData *data, NSError **error) { + id JSON = nil; + + SEL _JSONKitSelector = NSSelectorFromString(@"objectFromJSONDataWithParseOptions:error:"); + SEL _SBJSONSelector = NSSelectorFromString(@"JSONValue"); + SEL _YAJLSelector = NSSelectorFromString(@"yajl_JSONWithOptions:error:"); + + id _NSJSONSerializationClass = NSClassFromString(@"NSJSONSerialization"); + SEL _NSJSONSerializationSelector = NSSelectorFromString(@"JSONObjectWithData:options:error:"); + + +#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ + if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { + goto _af_nsjson_decode; + } +#endif + + if (_JSONKitSelector && [data respondsToSelector:_JSONKitSelector]) { + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[data methodSignatureForSelector:_JSONKitSelector]]; + invocation.target = data; + invocation.selector = _JSONKitSelector; + + NSUInteger parseOptionFlags = 0; + [invocation setArgument:&parseOptionFlags atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation + [invocation setArgument:error atIndex:3]; + + [invocation invoke]; + [invocation getReturnValue:&JSON]; + } else if (_SBJSONSelector && [NSString instancesRespondToSelector:_SBJSONSelector]) { + // Create a string representation of JSON, to use SBJSON -`JSONValue` category method + NSString *string = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[string methodSignatureForSelector:_SBJSONSelector]]; + invocation.target = string; + invocation.selector = _SBJSONSelector; + + [invocation invoke]; + [invocation getReturnValue:&JSON]; + } else if (_YAJLSelector && [data respondsToSelector:_YAJLSelector]) { + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[data methodSignatureForSelector:_YAJLSelector]]; + invocation.target = data; + invocation.selector = _YAJLSelector; + + NSUInteger yajlParserOptions = 0; + [invocation setArgument:&yajlParserOptions atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation + [invocation setArgument:error atIndex:3]; + + [invocation invoke]; + [invocation getReturnValue:&JSON]; + } else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) { +#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_ + _af_nsjson_decode: +#endif + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]]; + invocation.target = _NSJSONSerializationClass; + invocation.selector = _NSJSONSerializationSelector; + + [invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation + NSUInteger readOptions = 0; + [invocation setArgument:&readOptions atIndex:3]; + [invocation setArgument:error atIndex:4]; + + [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] raise]; + } + + return JSON; +} From 6c70e39584dd4711e019f515135bb9316272cf61 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Fri, 20 Jan 2012 14:35:19 -0800 Subject: [PATCH 4/4] Mark the AFJSON* functions as 'extern'. --- AFNetworking/AFJSONUtilities.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFJSONUtilities.h b/AFNetworking/AFJSONUtilities.h index d10737d5ec..ece26a0758 100644 --- a/AFNetworking/AFJSONUtilities.h +++ b/AFNetworking/AFJSONUtilities.h @@ -22,5 +22,5 @@ #import -NSData * AFJSONEncode(id object, NSError **error); -id AFJSONDecode(NSData *data, NSError **error); +extern NSData * AFJSONEncode(id object, NSError **error); +extern id AFJSONDecode(NSData *data, NSError **error);