Merge branch 'master' of github.com:AFNetworking/AFNetworking

This commit is contained in:
Mattt Thompson 2012-04-14 21:42:25 -07:00
commit bf6e45eac9

View file

@ -203,13 +203,16 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
} }
- (void)setCompletionBlock:(void (^)(void))block { - (void)setCompletionBlock:(void (^)(void))block {
__block AFHTTPRequestOperation *blockSelf = self;
dispatch_once_t *blockOnceToken = &_onceToken;
[super setCompletionBlock:^{ [super setCompletionBlock:^{
if(block) { if(block) {
block(); block();
} }
// Dispatch once is used to ensure that setting the block with this block will not cause multiple calls to 'dispatch_group_leave' // Dispatch once is used to ensure that setting the block with this block will not cause multiple calls to 'dispatch_group_leave'
dispatch_once(&_onceToken, ^{ dispatch_once(blockOnceToken, ^{
dispatch_group_leave(self.dispatchGroup); dispatch_group_leave(blockSelf.dispatchGroup);
}); });
}]; }];
} }