您的位置:首页 > 移动开发 > IOS开发

ios runtime系列 method_exchangeImplementations方法

2017-02-07 15:28 274 查看
- (void)viewDidLoad
{
[super viewDidLoad];

Method m1 = class_getInstanceMethod([self class], @selector(method1));

Method m2 = class_getInstanceMethod([self class], @selector(method2));

[self method1];

[self method2];

method_exchangeImplementations(m1, m2);

[self method1];

[self method2];
}

- (void)method1
{
NSLog(@"%s", __func__);
}
- (void)method2
{
NSLog(@"%s", __func__);
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: