美文网首页
iOS IMP和SEL

iOS IMP和SEL

作者: crazyfox | 来源:发表于2017-02-27 11:18 被阅读78次

    SEL : 类成员方法的指针,但不同于C语言中的函数指针,函数指针直接保存了方法的地址,但SEL只是方法编号。

    IMP:一个函数指针,保存了方法的地址

    直接调用IMP需要配置

    - (void)selAndIMP

    {

    SELmethodId =@selector(changeMethod);

    NSString*methodString =NSStringFromSelector(methodId);

    NSLog(@"%@",methodString);

    IMPmethodPoint = [selfmethodForSelector:methodId];

    idreturnObjc = methodPoint(self,methodId);

    }

    -(void)changeMethod

    {

    NSLog(@"changeMethod");

    }

    相关文章

      网友评论

          本文标题:iOS IMP和SEL

          本文链接:https://www.haomeiwen.com/subject/uhewwttx.html