Skip to content

Instantly share code, notes, and snippets.

@stigi
Created July 30, 2014 12:23
Show Gist options
  • Save stigi/11cccd6778ebd83aae49 to your computer and use it in GitHub Desktop.
Save stigi/11cccd6778ebd83aae49 to your computer and use it in GitHub Desktop.
Bad idea
MyCrazyBlock block = ^(BOOL *stop) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
// do some work
dispatch_async(dispatch_get_main_queue(), ^{
*stop = YES;
});
});
};
// in your object
if (block) block(&self.shouldStop);
@hiDominik
Copy link

just a wild guess, but what if you call the block with a weak pointer to self?

__weak typeof(self) weakSelf = self;
if (block) block(&weakSelf.shouldStop);

@stigi
Copy link
Author

stigi commented Jul 30, 2014

Please ignore the fact that setting the stop BOOL asynchronously never worked anyway ;)

@stigi
Copy link
Author

stigi commented Jul 30, 2014

@hiDominik: should not make any difference, as ARC only manages object retain counts. we're dealing with a pointer into an objects memory space here. Nothing that could be retained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment