From 3997dbb7e9d942edff59ff66d484b6b74556a868 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 18:46:04 +1100 Subject: [PATCH] Fixes warning: multiple methods named 'selector' found [-Werror,-Wstrict-selector-match] --- AFNetworking/AFHTTPClient.m | 6 ++++-- AFNetworking/AFHTTPRequestOperation.m | 4 ++++ AFNetworking/AFURLConnectionOperation.m | 10 +++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 9a54f48..b366be2 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -150,7 +150,8 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; }]; } else if([value isKindOfClass:[NSArray class]]) { - [value enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { + NSArray *array = value; + [array enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; }]; } else { @@ -295,7 +296,8 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ block(status); } - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; } static const void * AFNetworkReachabilityRetainCallback(const void *info) { diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index c67fe14..2525cbf 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -30,6 +30,10 @@ #define AF_CAST_TO_BLOCK __bridge void * #endif +// We do a little bit of duck typing in this file which can trigger this warning. Turn it off for this source file. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wstrict-selector-match" + NSSet * AFContentTypesFromHTTPHeader(NSString *string) { if (!string) { return nil; diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 44bc11d..7c756cf 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -310,12 +310,14 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat [self didChangeValueForKey:oldStateKey]; [self didChangeValueForKey:newStateKey]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + switch (state) { case AFOperationExecutingState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + [notificationCenter postNotificationName:AFNetworkingOperationDidStartNotification object:self]; break; case AFOperationFinishedState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; break; default: break; @@ -351,7 +353,9 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat if ([self isExecuting]) { [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; } self.state = AFOperationPausedState;