Skip to content

Instantly share code, notes, and snippets.

@OneSadCookie
Created September 20, 2011 18:21
Show Gist options
  • Save OneSadCookie/1229867 to your computer and use it in GitHub Desktop.
Save OneSadCookie/1229867 to your computer and use it in GitHub Desktop.
block hilarity
#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