Created
April 22, 2012 08:42
-
-
Save onevcat/2462760 to your computer and use it in GitHub Desktop.
dynamicMethod
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
void dynamicMethodIMP(id self, SEL _cmd) | |
{ | |
// implementation .... | |
} | |
//该方法在OC消息转发生效前被调用 | |
+ (BOOL) resolveInstanceMethod:(SEL)aSEL | |
{ | |
if (aSEL == @selector(resolveThisMethodDynamically)) | |
{ | |
//向[self class]中新加入返回为void的实现,SEL名字为aSEL,实现的具体内容为dynamicMethodIMP | |
class_addMethod([self class], aSEL, (IMP) dynamicMethodIMP, "v@:"); | |
return YES; | |
} | |
return [super resolveInstanceMethod:aSel]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment