2018-01-08

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;

}

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
    40c0490e5268阅读 1,853评论 0 9
  • 我们常常会听说 Objective-C 是一门动态语言,那么这个「动态」表现在哪呢?我想最主要的表现就是 Obje...
    Ethan_Struggle阅读 2,239评论 0 7
  • 继上Runtime梳理(四) 通过前面的学习,我们了解到Objective-C的动态特性:Objective-C不...
    小名一峰阅读 787评论 0 3
  • 转载:http://yulingtianxia.com/blog/2014/11/05/objective-c-r...
    F麦子阅读 780评论 0 2
  • 本文转载自:http://yulingtianxia.com/blog/2014/11/05/objective-...
    ant_flex阅读 815评论 0 1