Post

Replies

Boosts

Views

Activity

iOS18.0 及 iOS18.1 必现崩溃。- (BOOL) respondsToSelector:(SEL)aSelector 中 aSelector 可能无效,导致必现崩溃
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 是一个非法指针,访问就会崩溃
1
0
288
Sep ’24
iOS18.0 and iOS18.1 will inevitably crash. - (BOOL) respondsToSelector:(SEL)aSelector aSelector may be invalid, resulting in a crash
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
0
0
201
Sep ’24
iOS18 Must appear crash bug
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 是一个非法指针,访问就会崩溃
1
0
222
Sep ’24