Skip to content

Instantly share code, notes, and snippets.

@JaviSoto
Last active December 19, 2015 16:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JaviSoto/5986283 to your computer and use it in GitHub Desktop.
Save JaviSoto/5986283 to your computer and use it in GitHub Desktop.
ms_invoke_block_if_not_nil()
#define ms_invoke_block_if_not_nil(BLOCK, ...) do { typeof((BLOCK)) b = (BLOCK); if (b) b(__VA_ARGS__); } while(0)
// Usage:
void (^block)(id, id, id) = void(^)(id parameter1, id parameter2, id parameter3) {
// ...
};
ms_invoke_block_if_not_nil(block, parameter1, parameter2, parameter3);
// As opposed to:
if (block) {
block(parameter1, parameter2, parameter3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment