From c39053dbd254bd729929284647f36d6670b3a2e2 Mon Sep 17 00:00:00 2001 From: Stephan Diederich Date: Thu, 15 Aug 2013 22:31:53 +0200 Subject: [PATCH] better completion block handling make sure to remove the completion block once done. This should help in cases the user forgot to do the weak-dance as well as when the copied objects are release --- Classes/BITHTTPOperation.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Classes/BITHTTPOperation.m b/Classes/BITHTTPOperation.m index 0f81c8672c..cb232c30ad 100644 --- a/Classes/BITHTTPOperation.m +++ b/Classes/BITHTTPOperation.m @@ -93,15 +93,16 @@ } - (void)setCompletion:(BITNetworkCompletionBlock)completion { - __weak typeof(self) weakSelf = self; - if(nil == completion) { + if(!completion) { [super setCompletionBlock:nil]; } else { + __weak typeof(self) weakSelf = self; [super setCompletionBlock:^{ typeof(self) strongSelf = weakSelf; if(strongSelf) { dispatch_async(dispatch_get_main_queue(), ^{ completion(strongSelf, strongSelf->_data, strongSelf->_error); + [strongSelf setCompletionBlock:nil]; }); } }];