+ (void)load {
// 开发环境 查看哪个viewController将出现
#ifdef DEBUG
//原本的viewWillAppear方法
Method viewWillAppear = class_getInstanceMethod(self, @selector(viewWillAppear:));
//需要替换成 能够输出日志的viewWillAppear
Method logViewWillAppear = class_getInstanceMethod(self, @selector(logViewWillAppear:));
//两方法进行交换
method_exchangeImplementations(viewWillAppear, logViewWillAppear);
#endif
}
- (void)logViewWillAppear:(BOOL)animated {
NSString *className = NSStringFromClass([self class]);
DYInfoLog(@"%@ will appear", className);
[self logViewWillAppear:animated];
}
参考:
点击打开链接
利用 runtime 打印当前所显示的控制器
最新推荐文章于 2018-11-19 17:29:18 发布