1、 hook respondsToSelector: 接口,比如 hook 后的接口名字为 yy_respondsToSelector:
2、在 yy_respondsToSelector 中使用传入的参数 aSelector。示例代码如下:
(BOOL) yy_respondsToSelector:(SEL)aSelector {
if ([self yy_respondsToSelector:aSelector]) {
return YES;
}
if ([self.selectorNameArray containsObject:NSStringFromSelector(aSelector)]) {
return YES;
}
return NO;
}
2、在自定义 UIViewController,比如 YYViewController,实现下述代码
(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSMutableArray *vcs = [[NSMutableArray alloc]init];
[vcs addObject:[[UIViewController alloc] init] ];
[vcs addObject:[[UIViewController alloc] init] ];
self.navigationController.viewControllers = vcs;
}
3、当页面 YYViewController加载并执行 viewDidAppear 时候, App 一定会出现崩溃,因为 aSelector 是一个非法指针,访问就会崩溃
Post
Replies
Boosts
Views
Activity
Hook respondsToSelector: interface. For example, the name of the hooked interface is yy_respondsToSelector: 2. Use the passed parameter aSelector in yy_respondsToSelector. The sample code is as follows:
(BOOL) yy_respondsToSelector:(SEL)aSelector { if ([self yy_respondsToSelector:aSelector]) { return YES; }
if ([self.selectorNameArray containsObject:NSStringFromSelector(aSelector)]) { return YES; } return NO;
}
2. In a custom UIViewController, such as YYViewController, implement the following code
(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated];
NSMutableArray *vcs = [[NSMutableArray alloc]init]; [vcs addObject:[[UIViewController alloc] init] ]; [vcs addObject:[[UIViewController alloc] init] ]; self.navigationController.viewControllers = vcs;
}
3. When the page YYViewController is loaded and viewDidAppear is executed, App There will definitely be a crash, because aSelector is an illegal pointer, and access will crash
1、 hook respondsToSelector: 接口,比如 hook 后的接口名字为 yy_respondsToSelector: 2、在 yy_respondsToSelector 中使用传入的参数 aSelector。示例代码如下:
(BOOL) yy_respondsToSelector:(SEL)aSelector { if ([self yy_respondsToSelector:aSelector]) { return YES; }
if ([self.selectorNameArray containsObject:NSStringFromSelector(aSelector)]) { return YES; } return NO;
}
2、在自定义 UIViewController,比如 YYViewController,实现下述代码
(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated];
NSMutableArray *vcs = [[NSMutableArray alloc]init]; [vcs addObject:[[UIViewController alloc] init] ]; [vcs addObject:[[UIViewController alloc] init] ]; self.navigationController.viewControllers = vcs;
}
3、当页面 YYViewController加载并执行 viewDidAppear 时候, App 一定会出现崩溃,因为 aSelector 是一个非法指针,访问就会崩溃