zoukankan      html  css  js  c++  java
  • iOS runtime exchange methods

    void bd_exchangeInstanceMethod(Class aClass, SEL oldSEL, SEL newSEL);
    void bd_exchageClassMethod(Class aClass, SEL oldSEL, SEL newSEL);
    #import <objc/runtime.h>
    
    void bd_exchangeInstanceMethod(Class aClass, SEL oldSEL, SEL newSEL)
    {
        Method oldMethod = class_getInstanceMethod(aClass, oldSEL);
        assert(oldMethod);
        Method newMethod = class_getInstanceMethod(aClass, newSEL);
        assert(newMethod);
        method_exchangeImplementations(oldMethod, newMethod);
    }
    
    void bd_exchageClassMethod(Class aClass, SEL oldSEL, SEL newSEL)
    {
        Method oldClsMethod = class_getClassMethod(aClass, oldSEL);
        assert(oldClsMethod);
        Method newClsMethod = class_getClassMethod(aClass, newSEL);
        assert(newClsMethod);
        method_exchangeImplementations(oldClsMethod, newClsMethod);
    }
    
  • 相关阅读:
    cookie行为试验(一)
    指针内容的引用
    多线程协同
    xss攻击
    _com_error e
    操作符重载
    c++对象中的成员变量地址分布
    常对象指针
    COM调用2
    cookie行为试验(二)
  • 原文地址:https://www.cnblogs.com/KingQiangzi/p/7278881.html
Copyright © 2011-2022 走看看