Skip to content

Instantly share code, notes, and snippets.



Last active Aug 24, 2016
What would you like to do?
#!/usr/bin/env objc-run
@import Foundation;
@interface NSBlock // bite me
@implementation NSBlock (invoke)
- (void) invoke
((void (^)(void))self)();
int main() {
void (^foo)(void) = ^{ NSLog(@"yolo"); };
void (^bar)(void) = nil;
bar(); // <- this crashes
[foo invoke];
[bar invoke]; // <- this doesn’t

This comment has been minimized.

Copy link

@mickeyl mickeyl commented Aug 24, 2016

That's clever!

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