Created
September 30, 2011 19:07
-
-
Save mikeash/1254684 to your computer and use it in GitHub Desktop.
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
dispatch_block_t RecursiveBlock(void (^block)(dispatch_block_t recurse)) | |
{ | |
// assuming ARC, so no explicit copy | |
return ^{ block(RecursiveBlock(block)); }; | |
} | |
typedef void (^OneParameterBlock)(id parameter); | |
OneParameterBlock RecursiveBlock1(void (^block)(OneParameterBlock recurse, id parameter)) | |
{ | |
return ^{ block(RecursiveBlock1(block), parameter) }; | |
} | |
use: | |
dispatch_block_t block = RecursiveBlock(^(dispatch_block_t recurse) { | |
if(!done) | |
recurse(); | |
else | |
... | |
}); | |
block(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment