Skip to content

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

Description

@dengchaojie

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,上面两个只是字符串而已。

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions