Skip to content

Commit

Permalink
Null checking completion blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeneka committed Apr 13, 2017
1 parent f7e7712 commit a58ab52
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions CPAProxy/CPAProxyManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ - (void)handleInitialBootstrapProgressResponse:(NSString *)response
__weak typeof(self)weakSelf = self;
dispatch_async(self.callbackQueue, ^{
__strong typeof(weakSelf)strongSelf = weakSelf;
strongSelf.progressBlock(progress,summaryString);
if (strongSelf.progressBlock) {
strongSelf.progressBlock(progress, summaryString);
}
});
}

Expand All @@ -294,10 +296,9 @@ - (void)handleInitialBootstrapProgressResponse:(NSString *)response
__weak typeof(self)weakSelf = self;
dispatch_async(self.callbackQueue, ^{
__strong typeof(weakSelf)strongSelf = weakSelf;
if (!strongSelf) {
return;
if (strongSelf.completionBlock) {
strongSelf.completionBlock(socksHost, socksPort, nil);
}
strongSelf.completionBlock(socksHost, socksPort, nil);
strongSelf.completionBlock = nil;
strongSelf.progressBlock = nil;
});
Expand Down Expand Up @@ -338,7 +339,9 @@ - (void)failWithError:(NSError *)error
__weak typeof(self)weakSelf = self;
dispatch_async(self.callbackQueue, ^{
__strong typeof(weakSelf)strongSelf = weakSelf;
strongSelf.completionBlock(nil,0,error);
if (strongSelf.completionBlock) {
strongSelf.completionBlock(nil, 0, error);
}
strongSelf.completionBlock = nil;
strongSelf.progressBlock = nil;
});
Expand Down

0 comments on commit a58ab52

Please sign in to comment.