我正在使用第三方库并在我的代码中调用方法时随机面临崩溃。
崩溃日志说无法识别的选择器 viewControllers 发送到 .
崩溃日志:由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[ThirdPartyController viewControllers]:无法识别的选择器发送到实例 0x1e959bc0”
但是,如果您在下面看到,我在调用此方法之前已经采取了所有安全处理。有什么问题。
+ (UINavigationController *)currentNavigationController:(UINavigationController *)iPreviousNavigationController {
UINavigationController *aCurrentNavigationController = iPreviousNavigationController;
UINavigationController *aChildNavigationController = (UINavigationController *)[iPreviousNavigationController modalViewController];
if (aChildNavigationController) {
aCurrentNavigationController = [self currentNavigationController:aChildNavigationController];
}
return aCurrentNavigationController;
}
+ (UIViewController *)currentViewController:(UINavigationController *)iPreviousNavigationController {
UINavigationController *aCurrentNavigationController = [self currentNavigationController:iPreviousNavigationController];
if (!aCurrentNavigationController || ![aCurrentNavigationController respondsToSelector:@selector(viewControllers)]) {
aCurrentNavigationController = [self applicationDelegate].navigationController;
}
UIViewController *aCurrentViewController;
if ([aCurrentNavigationController respondsToSelector:@selector(viewControllers)]) {
aCurrentViewController = [aCurrentNavigationController.viewControllers lastObject];
}
return aCurrentViewController;
}