cocoa之高级开发RunTime高级API
来源:互联网 发布:c语言两条竖线运算 编辑:程序博客网 时间:2024/05/01 05:40
系统类的方法实现部分替换
Method m1 = class_getInstanceMethod([NSStringclass],@selector(lowercaseString));Method m2 = class_getInstanceMethod([NSStringclass],@selector(uppercaseString));method_exchangeImplementations(m1, m2);log list: (lldb)po [@"assAAAAss" lowercaseString]ASSAAAASS(lldb) po [@"sssKAAAss" uppercaseString]ssskaaass
自定义类的方法实现部分替换
在这里要说到一个黑马的典型死循环(人称自己++自己)
(void)viewDidLoad {[selfmethodSetImplementation];[self test];} -(void)test{ [self test];}
如何在不改变源码的基础上干掉死循环
- (void) methodSetImplementation { Method method = class_getInstanceMethod([ViewController class],@selector(justLog1));IMP originalImp = method_getImplementation(method);Method m1 = class_getInstanceMethod([ViewController class],@selector(test)); method_setImplementation(m1, originalImp);}- (void) justLog1 { NSLog(@"justLog1");//完美实现实例方法替换}
0 0
- cocoa之高级开发RunTime高级API
- cocoa之高级开发RunTime初级基本变数
- IOS高级开发~Runtime
- IOS高级开发 runtime(1)
- RunTime高级
- IOS高级开发~Runtime(一)
- IOS高级开发~Runtime(二)
- IOS高级开发~Runtime(三)
- IOS高级开发~Runtime(四)
- IOS高级开发~Runtime(一)
- IOS高级开发~Runtime(一)
- IOS高级开发~Runtime(二)
- IOS高级开发~Runtime(三)
- IOS高级开发~Runtime(四)
- IOS_Learing高级开发~Runtime(一)
- iosLearing高级开发~Runtime(二)
- iosLearing高级开发~Runtime(四)
- IOS高级开发~Runtime(一)
- Year summary
- 欧拉函数
- 零基础学python-8.6 字典的基本操作与原处修改
- Opencv中XML文件的写入
- [BZOJ1816][Cqoi2010]扑克牌
- cocoa之高级开发RunTime高级API
- hive shell命令
- [HDU 2955 Robberies] 入门DP
- 自定义Dialog、PopupWindow、通知Notification
- iter 和生成器
- HDU5399
- Java中>> 与 >>> 的区别
- Linux内核工程导论——用户空间设备管理
- memcpy引发的C常见指针问题