Merge pull request #182 from jparise/nsjson-labels
Conditionally define the _af_nsjson_* labels.
This commit is contained in:
commit
dcb5eae1e5
1 changed files with 28 additions and 26 deletions
|
|
@ -75,19 +75,20 @@ static NSData * AFJSONEncode(id object, NSError **error) {
|
||||||
*error = [[[NSError alloc] initWithDomain:NSStringFromClass([exception class]) code:0 userInfo:[exception userInfo]] autorelease];
|
*error = [[[NSError alloc] initWithDomain:NSStringFromClass([exception class]) code:0 userInfo:[exception userInfo]] autorelease];
|
||||||
}
|
}
|
||||||
} else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) {
|
} else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) {
|
||||||
_af_nsjson_encode: {
|
#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_
|
||||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]];
|
_af_nsjson_encode:
|
||||||
invocation.target = _NSJSONSerializationClass;
|
#endif
|
||||||
invocation.selector = _NSJSONSerializationSelector;
|
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
|
[invocation setArgument:&object atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
|
||||||
NSUInteger writeOptions = 0;
|
NSUInteger writeOptions = 0;
|
||||||
[invocation setArgument:&writeOptions atIndex:3];
|
[invocation setArgument:&writeOptions atIndex:3];
|
||||||
[invocation setArgument:error atIndex:4];
|
[invocation setArgument:error atIndex:4];
|
||||||
|
|
||||||
[invocation invoke];
|
[invocation invoke];
|
||||||
[invocation getReturnValue:&data];
|
[invocation getReturnValue:&data];
|
||||||
}
|
|
||||||
} else {
|
} 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];
|
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];
|
[[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 invoke];
|
||||||
[invocation getReturnValue:&JSON];
|
[invocation getReturnValue:&JSON];
|
||||||
} else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) {
|
} else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) {
|
||||||
_af_nsjson_decode: {
|
#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_
|
||||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]];
|
_af_nsjson_decode:
|
||||||
invocation.target = _NSJSONSerializationClass;
|
#endif
|
||||||
invocation.selector = _NSJSONSerializationSelector;
|
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
|
[invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
|
||||||
NSUInteger readOptions = 0;
|
NSUInteger readOptions = 0;
|
||||||
[invocation setArgument:&readOptions atIndex:3];
|
[invocation setArgument:&readOptions atIndex:3];
|
||||||
[invocation setArgument:error atIndex:4];
|
[invocation setArgument:error atIndex:4];
|
||||||
|
|
||||||
[invocation invoke];
|
[invocation invoke];
|
||||||
[invocation getReturnValue:&JSON];
|
[invocation getReturnValue:&JSON];
|
||||||
}
|
|
||||||
} else {
|
} 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];
|
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];
|
[[NSException exceptionWithName:NSInternalInconsistencyException reason:NSLocalizedString(@"No JSON parsing functionality available", nil) userInfo:userInfo] raise];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue