Asynchronously posting all notifications by dispatching to main

This commit is contained in:
Mattt Thompson 2012-12-27 12:22:46 -05:00
parent 7b685fe35e
commit a9b9ebee37
2 changed files with 7 additions and 2 deletions

View file

@ -301,7 +301,9 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ
block(status); block(status);
} }
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]];
});
} }
static const void * AFNetworkReachabilityRetainCallback(const void *info) { static const void * AFNetworkReachabilityRetainCallback(const void *info) {

View file

@ -385,7 +385,10 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
if ([self isExecuting]) { if ([self isExecuting]) {
[self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
});
} }
self.state = AFOperationPausedState; self.state = AFOperationPausedState;