Created
September 12, 2012 00:57
-
-
Save plantpurecode/3703384 to your computer and use it in GitHub Desktop.
Recursion, with blocks!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!