From 6a46815eafdb3e8b5f46f94502756cd9b226d7ef Mon Sep 17 00:00:00 2001 From: Joel Parsons Date: Mon, 11 Mar 2013 13:15:19 +0000 Subject: [PATCH 1/2] The documentations states registered operation classes are consulted to the reverse order in which they are registered. New registrations are added to the beginning of the array in the register implementation. Fixed using the reverseObjectEnumerator when iterating the array which produced the opposite of documented behaviour. fixes #794 --- AFNetworking/AFHTTPClient.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f9d2166..d4bba2f 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -517,12 +517,12 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) { failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure { AFHTTPRequestOperation *operation = nil; - NSString *className = nil; - NSEnumerator *enumerator = [self.registeredHTTPOperationClassNames reverseObjectEnumerator]; - while (!operation && (className = [enumerator nextObject])) { + + for (NSString * className in self.registeredHTTPOperationClassNames) { Class op_class = NSClassFromString(className); if (op_class && [op_class canProcessRequest:urlRequest]) { operation = [(AFHTTPRequestOperation *)[op_class alloc] initWithRequest:urlRequest]; + break; } } From 1bd7faf9644337905b217506158a6e95166634e8 Mon Sep 17 00:00:00 2001 From: Joel Parsons Date: Tue, 12 Mar 2013 10:47:45 +0000 Subject: [PATCH 2/2] changed op_class variable to more objective-c style variable name operationClass --- AFNetworking/AFHTTPClient.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index d4bba2f..d250397 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -519,9 +519,9 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) { AFHTTPRequestOperation *operation = nil; for (NSString * className in self.registeredHTTPOperationClassNames) { - Class op_class = NSClassFromString(className); - if (op_class && [op_class canProcessRequest:urlRequest]) { - operation = [(AFHTTPRequestOperation *)[op_class alloc] initWithRequest:urlRequest]; + Class operationClass = NSClassFromString(className); + if (operationClass && [operationClass canProcessRequest:urlRequest]) { + operation = [(AFHTTPRequestOperation *)[operationClass alloc] initWithRequest:urlRequest]; break; } }