Skip to content

Instantly share code, notes, and snippets.

@OneSadCookie
Created July 30, 2011 22:25
Show Gist options
  • Save OneSadCookie/1116076 to your computer and use it in GitHub Desktop.
Save OneSadCookie/1116076 to your computer and use it in GitHub Desktop.
// clang __block_later.m -o __block_later -framework Foundation
// ./__block_later
#import <Foundation/Foundation.h>
static void (^ the_block)(void);
static void make_the_block(void)
{
__block int n = 0;
the_block = _Block_copy(^{
printf("This block has been called %d times\n", ++n);
});
}
int main()
{
make_the_block();
for (int i = 0; i < 10; ++i)
{
the_block();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment