美文网首页
简书 MarkDown 代码框的使用

简书 MarkDown 代码框的使用

作者: Keep_FighterLS | 来源:发表于2015-11-02 21:08 被阅读10477次

还是第一次使用简书的markDown

献给写作者的 Markdown 新手指南

代码框
runtime method swizzling

//静态就交换静态,实例方法就交换实例方法
void Swizzle(Class c, SEL origSEL, SEL newSEL)
{
    Method origMethod = class_getInstanceMethod(c, origSEL);
    Method newMethod = nil;
    if (!origMethod) {
        origMethod = class_getClassMethod(c, origSEL);
        if (!origMethod) {
            return;
        }
        newMethod = class_getClassMethod(c, newSEL);
        if (!newMethod) {
            return;
        }
    }else{
        newMethod = class_getInstanceMethod(c, newSEL);
        if (!newMethod) {
            return;
        }
    }
    
    //自身已经有了就添加不成功,直接交换即可
    if(class_addMethod(c, origSEL, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))){
        class_replaceMethod(c, newSEL, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
    }else{
        method_exchangeImplementations(origMethod, newMethod);
    }
}
搞定,可以了,以后继续玩,好开心

相关文章

网友评论

      本文标题:简书 MarkDown 代码框的使用

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