Created
April 18, 2015 00:14
-
-
Save segiddins/e60ffd0975b01c655d74 to your computer and use it in GitHub Desktop.
I swear, I only did this for an experiment
This file contains hidden or 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(int argc, char *argv[]) { | |
@autoreleasepool { | |
IMP imp = imp_implementationWithBlock(^id(id self, id block, id arg){ | |
NSLog(@"self: %@, arg: %@", self, arg); | |
return self; | |
}); | |
class_addMethod([NSObject class], @selector (foo), imp, "@@:@"); | |
NSObject *object = [[NSObject alloc] init]; | |
id ret = [object performSelector:@selector (foo) withObject:@"Hi!"]; | |
NSLog(@"ret: %@", ret); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment