首页 > 其他 > 详细

Swizzle 交换2个方法的实现

时间:2016-08-17 22:42:08      阅读:183      评论:0      收藏:0      [点我收藏+]

#import "UIImage+image.h"
#import <objc/runtime.h>
@implementation UIImage (image)
+(void)load

//只要分类被装载到内存中 就会被调用一次

{
    Method ohter=class_getClassMethod([UIImage class], @selector(imageWithName:));
    Method origin = class_getClassMethod([UIImage class], @selector(imageNamed:));
    method_exchangeImplementations(ohter, origin);
}
+(UIImage*)imageWithName:(NSString*)name{
    NSLog(@"=====");
    [UIImage imageWithName:name];
    return nil;
}

Swizzle 交换2个方法的实现

原文:http://www.cnblogs.com/xiezefeng/p/5781891.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!