码迷,mamicode.com
首页 > 其他好文 > 详细

Swizzle 交换2个方法的实现

时间:2016-08-17 22:43:43      阅读:159      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!