设为首页 加入收藏

TOP

super performSelector: 解决调用父类私有方法的问题
2019-09-25 18:11:22 】 浏览:73
Tags:super performSelector: 解决 调用 私有 方法 问题

super performSelector: 解决objc调用父类私有方法的问题

  Objc中[super performSelector: ...]并不会像其他语言一样能良好的工作。super只是编译器符号。

  想要安全和快速的调用父类的方法是直接调用父类方法的函数地址:

    Method md = class_getInstanceMethod(class_getSuperclass(self.class), @selector(XXXXX:));

    IMP imp = method_getImplementation(md);

    void(*super_imp)(id,SEL,id) = (void*)imp;

    super_imp(self, @selector(XXXXX:), 参数1, 参数2, 参数3,... ...);

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Method Swizzling 下一篇《垃圾分类助手-生活的好帮手-技..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目