Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新的IMP的那段代码,怎么在运行时添加上去的? #861

Open
dengchaojie opened this issue Apr 29, 2020 · 0 comments
Open

新的IMP的那段代码,怎么在运行时添加上去的? #861

dengchaojie opened this issue Apr 29, 2020 · 0 comments

Comments

@dengchaojie
Copy link

1 实现原理详解有下面的代码,是新的IMP,怎么在运行时添加上去的?
static void viewDidLoadIMP (id slf, SEL sel) {
JSValue *jsFunction = …;
[jsFunction callWithArguments:nil];
}
我问的不是这个class_replaceMethod(cls, selector, viewDidLoadIMP, typeDescription);

2 我下面的理解,大家觉得是否正确:-ORIGviewWillAppear: 和 -_JPviewWillAppear,怎么添加上的?
回答,这两个可以当成字符串。第一个,先转成sel,之后class_addMethod指向原来的imp;第二个,先转成sel,之后指向新的imp。所以真正添加的是新的imp,上面两个只是字符串而已。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant