Created
September 20, 2011 18:21
-
-
Save OneSadCookie/1229867 to your computer and use it in GitHub Desktop.
block hilarity
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
#import <objc/runtime.h> | |
#import <Foundation/Foundation.h> | |
int main() | |
{ | |
Class c = [^(){} class]; | |
BOOL ok = class_addMethod( | |
c, | |
@selector(invoke), | |
imp_implementationWithBlock(^(void (^self)(void)){ | |
self(); | |
}), | |
"v16@0:8"); | |
NSLog(@"%d", (int)ok); | |
[^(void){ NSLog(@"hi"); } invoke]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment