[#417] Fixing compilation error in Xcode 4.5

This commit is contained in:
Mattt Thompson 2012-09-14 09:02:32 -07:00
parent 95f2f53604
commit c8d9f79ef9

View file

@ -23,6 +23,13 @@
#import "AFHTTPRequestOperation.h" #import "AFHTTPRequestOperation.h"
#import <objc/runtime.h> #import <objc/runtime.h>
// Workaround for change in imp_implementationWithBlock()
#ifdef __IPHONE_6_0
#define AF_CAST_TO_BLOCK id
#else
#define AF_CAST_TO_BLOCK __bridge void *
#endif
NSString * const kAFNetworkingIncompleteDownloadDirectoryName = @"Incomplete"; NSString * const kAFNetworkingIncompleteDownloadDirectoryName = @"Incomplete";
NSSet * AFContentTypesFromHTTPHeader(NSString *string) { NSSet * AFContentTypesFromHTTPHeader(NSString *string) {
@ -54,9 +61,9 @@ NSSet * AFContentTypesFromHTTPHeader(NSString *string) {
return [NSSet setWithSet:mutableContentTypes]; return [NSSet setWithSet:mutableContentTypes];
} }
static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL selector, void *block) { static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL selector, id block) {
Method originalMethod = class_getClassMethod(klass, selector); Method originalMethod = class_getClassMethod(klass, selector);
IMP implementation = imp_implementationWithBlock((__bridge id)(block)); IMP implementation = imp_implementationWithBlock((AF_CAST_TO_BLOCK)block);
class_replaceMethod(objc_getMetaClass([NSStringFromClass(klass) UTF8String]), selector, implementation, method_getTypeEncoding(originalMethod)); class_replaceMethod(objc_getMetaClass([NSStringFromClass(klass) UTF8String]), selector, implementation, method_getTypeEncoding(originalMethod));
} }
@ -266,7 +273,7 @@ NSString * AFCreateIncompleteDownloadDirectoryPath(void) {
+ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes { + (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes {
NSMutableIndexSet *mutableStatusCodes = [[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]]; NSMutableIndexSet *mutableStatusCodes = [[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]];
[mutableStatusCodes addIndexes:statusCodes]; [mutableStatusCodes addIndexes:statusCodes];
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), (__bridge void *)^(id _self) { AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(id _self) {
return mutableStatusCodes; return mutableStatusCodes;
}); });
} }
@ -278,7 +285,7 @@ NSString * AFCreateIncompleteDownloadDirectoryPath(void) {
+ (void)addAcceptableContentTypes:(NSSet *)contentTypes { + (void)addAcceptableContentTypes:(NSSet *)contentTypes {
NSMutableSet *mutableContentTypes = [[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES]; NSMutableSet *mutableContentTypes = [[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES];
[mutableContentTypes unionSet:contentTypes]; [mutableContentTypes unionSet:contentTypes];
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), (__bridge void *)^(id _self) { AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(id _self) {
return mutableContentTypes; return mutableContentTypes;
}); });
} }