Merge branch 'master' of github.com:AFNetworking/AFNetworking

This commit is contained in:
Mattt Thompson 2012-01-20 15:43:48 -08:00
commit 77dc7aaaed
2 changed files with 30 additions and 26 deletions

View file

@ -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;
#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 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];
}
[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;
#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 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];
}
[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];

View file

@ -24,6 +24,7 @@
#include <Availability.h>
#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;