Created
June 19, 2014 12:37
-
-
Save tarunon/6e00d18cd96f7192fb44 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
@implementation NSObject (forSwift) | |
- (id)__performSelector:(SEL)aSelector | |
{ | |
Method m = class_getInstanceMethod(self.class, aSelector); | |
const char *types = method_copyReturnType(m); | |
if (strcmp("v", types)) { | |
return [self performSelector:aSelector]; | |
} else { | |
[self performSelector:aSelector]; | |
return nil; | |
} | |
} | |
- (void)addMethod:(void(^)())rambda | |
{ | |
id class = [self class]; | |
SEL sel = @selector(hoge); | |
IMP imp = imp_implementationWithBlock(rambda); | |
Method method = class_getInstanceMethod(class, sel); | |
class_addMethod(class, sel, imp, "v"); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment