Permalink
Browse files

dispatches network request start / end notifications asynchronously

Signed-off-by: Mattt Thompson <m@mattt.me>
  • Loading branch information...
1 parent 732cd2d commit 7b685fe35efd574fdd5b779c12ff2577f5a27814 @evadne evadne committed with mattt Dec 27, 2012
Showing with 13 additions and 11 deletions.
  1. +13 −11 AFNetworking/AFURLConnectionOperation.m
@@ -331,17 +331,19 @@ - (void)setState:(AFOperationState)state {
_state = state;
[self didChangeValueForKey:oldStateKey];
[self didChangeValueForKey:newStateKey];
-
- switch (state) {
- case AFOperationExecutingState:
- [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self];
- break;
- case AFOperationFinishedState:
- [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
- break;
- default:
- break;
- }
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ switch (state) {
+ case AFOperationExecutingState:
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self];
+ break;
+ case AFOperationFinishedState:
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
+ break;
+ default:
+ break;
+ }
+ });
}
[self.lock unlock];
}

0 comments on commit 7b685fe

Please sign in to comment.