Skip to content

Instantly share code, notes, and snippets.

@romyilano
Created April 7, 2019 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romyilano/bdfc6320e099dfae0c120dc150b8f74d to your computer and use it in GitHub Desktop.
Save romyilano/bdfc6320e099dfae0c120dc150b8f74d to your computer and use it in GitHub Desktop.
// https://stackoverflow.com/questions/23806751/strong-reference-to-a-weak-references-inside-blocks
__weak typeof(self) weakSelf = self;
void (^someBlock)(id) = ^(id data){
if (weakSelf != nil) {
// last remaining strong reference released by another thread.
// weakSelf is now set to nil.
[myArray addObject:weakSelf];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment