Skip to content

Instantly share code, notes, and snippets.

@krisselden
Created June 19, 2014 23:10
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 krisselden/447557b3235da375e1b6 to your computer and use it in GitHub Desktop.
Save krisselden/447557b3235da375e1b6 to your computer and use it in GitHub Desktop.
#define WEAKIFY(x) __weak typeof(x)weak_##x = x
#define STRONGIFY(x) __strong typeof(weak_##x)x = weak_##x
MyViewController * __block myController = [[MyViewController alloc] init…];
// ...
WEAKIFY(myController);
myController.completionHandler = ^(NSInteger result) {
STRONGIFY(myController);
[myController dismissViewControllerAnimated:YES completion:nil];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment