Skip to content

Instantly share code, notes, and snippets.

@plantpurecode
Created September 12, 2012 00:57
Show Gist options
  • Save plantpurecode/3703384 to your computer and use it in GitHub Desktop.
Save plantpurecode/3703384 to your computer and use it in GitHub Desktop.
Recursion, with blocks!
- (void)printRecursivelyUpTo:(NSUInteger)max {
__block dispatch_block_t block;
__block NSUInteger iterator = 0;
dispatch_block_t b = ^{
if(iterator == max) return;
NSLog(@"%u", iterator);
++iterator;
block();
};
block = b, block();
}
@MosheBerman
Copy link

Nice!

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