Restore iOS 4.0 compatibility.
Signed-off-by: Zachary Waldowski <zwaldowski@gmail.com>
This commit is contained in:
parent
904d6ba50d
commit
25620fe839
5 changed files with 18 additions and 12 deletions
|
|
@ -54,9 +54,9 @@ NSSet * AFContentTypesFromHTTPHeader(NSString *string) {
|
|||
return [NSSet setWithSet:mutableContentTypes];
|
||||
}
|
||||
|
||||
static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL selector, void *block) {
|
||||
static void AFSwizzleClassMethodWithImplementation(Class klass, SEL selector, IMP implementation) {
|
||||
Method originalMethod = class_getClassMethod(klass, selector);
|
||||
IMP implementation = imp_implementationWithBlock(block);
|
||||
if (method_getImplementation(originalMethod) != implementation)
|
||||
class_replaceMethod(objc_getMetaClass([NSStringFromClass(klass) UTF8String]), selector, implementation, method_getTypeEncoding(originalMethod));
|
||||
}
|
||||
|
||||
|
|
@ -261,6 +261,10 @@ NSString * AFCreateIncompleteDownloadDirectoryPath(void) {
|
|||
|
||||
#pragma mark - AFHTTPRequestOperation
|
||||
|
||||
static id AFStaticClassValueImplementation(id self, SEL _cmd) {
|
||||
return objc_getAssociatedObject([self class], _cmd);
|
||||
}
|
||||
|
||||
+ (NSIndexSet *)acceptableStatusCodes {
|
||||
return [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)];
|
||||
}
|
||||
|
|
@ -268,9 +272,9 @@ NSString * AFCreateIncompleteDownloadDirectoryPath(void) {
|
|||
+ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes {
|
||||
NSMutableIndexSet *mutableStatusCodes = [[[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]] autorelease];
|
||||
[mutableStatusCodes addIndexes:statusCodes];
|
||||
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(id _self) {
|
||||
return mutableStatusCodes;
|
||||
});
|
||||
SEL selector = @selector(acceptableStatusCodes);
|
||||
AFSwizzleClassMethodWithImplementation([self class], selector, (IMP)AFStaticClassValueImplementation);
|
||||
objc_setAssociatedObject([self class], selector, mutableStatusCodes, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
||||
}
|
||||
|
||||
+ (NSSet *)acceptableContentTypes {
|
||||
|
|
@ -280,9 +284,9 @@ NSString * AFCreateIncompleteDownloadDirectoryPath(void) {
|
|||
+ (void)addAcceptableContentTypes:(NSSet *)contentTypes {
|
||||
NSMutableSet *mutableContentTypes = [[[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES] autorelease];
|
||||
[mutableContentTypes unionSet:contentTypes];
|
||||
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(id _self) {
|
||||
return mutableContentTypes;
|
||||
});
|
||||
SEL selector = @selector(acceptableContentTypes);
|
||||
AFSwizzleClassMethodWithImplementation([self class], selector, (IMP)AFStaticClassValueImplementation);
|
||||
objc_setAssociatedObject([self class], selector, mutableContentTypes, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
||||
}
|
||||
|
||||
+ (BOOL)canProcessRequest:(NSURLRequest *)request {
|
||||
|
|
|
|||
2
CHANGES
2
CHANGES
|
|
@ -1,7 +1,5 @@
|
|||
= 1.0RC1 / 2012-04-25
|
||||
|
||||
* Note: 1.0RC1 Deprecates iOS < 4.3 compatibility because of the addition of `AFHTTPRequestOperation +addAcceptableStatusCodes / +addAcceptableContentTypes`
|
||||
|
||||
* Add `AFHTTPRequestOperation +addAcceptableStatusCodes /
|
||||
+addAcceptableContentTypes` to dynamically add acceptable status codes and
|
||||
content types on the class level (Mattt Thompson)
|
||||
|
|
|
|||
|
|
@ -381,6 +381,7 @@
|
|||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = Prefix.pch;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
|
|
@ -392,6 +393,7 @@
|
|||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = Prefix.pch;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ operation.outputStream = [NSOutputStream outputStreamToMemory];
|
|||
|
||||
## Requirements
|
||||
|
||||
AFNetworking requires either [iOS 4.3](http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS4.html%23//apple_ref/doc/uid/TP40009559-SW1) and above, or [Mac OS 10.6](http://developer.apple.com/library/mac/#releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW7) and above.
|
||||
AFNetworking requires either [iOS 4.0](http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS4.html) and above, or [Mac OS 10.6](http://developer.apple.com/library/mac/#releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW7) and above.
|
||||
|
||||
AFNetworking uses [`NSJSONSerialization`](http://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html) if it is available. If your app targets a platform where this class is not available you can include one of the following JSON libraries to your project for AFNetworking to automatically detect and use.
|
||||
|
||||
|
|
|
|||
|
|
@ -392,6 +392,7 @@
|
|||
GCC_WARN_SIGN_COMPARE = YES;
|
||||
GCC_WARN_UNUSED_PARAMETER = NO;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
|
|
@ -410,6 +411,7 @@
|
|||
GCC_WARN_SIGN_COMPARE = YES;
|
||||
GCC_WARN_UNUSED_PARAMETER = NO;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
WRAPPER_EXTENSION = app;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue