From 1aa5882788890c70e5473783caf7bba73d62d028 Mon Sep 17 00:00:00 2001 From: ixueadev Date: Wed, 1 Dec 2021 13:10:22 +0800 Subject: [PATCH] fix AppDelegate without window property crash. --- CYLTabBarController/CYLTabBarController.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CYLTabBarController/CYLTabBarController.m b/CYLTabBarController/CYLTabBarController.m index 9f511ec..4d17ba3 100644 --- a/CYLTabBarController/CYLTabBarController.m +++ b/CYLTabBarController/CYLTabBarController.m @@ -749,7 +749,10 @@ - (void)cyl_setTabBarController:(CYLTabBarController *)tabBarController { static inline UIWindow *getMainWindow(){ UIWindow *window = nil; - window = UIApplication.sharedApplication.delegate.window; + if ([UIApplication.sharedApplication.delegate respondsToSelector:@selector(window)]) { + //兼容新版项目结构,也就是AppDelegate没有window的情况 + window = UIApplication.sharedApplication.delegate.window; + } if (!window) { if (@available(iOS 13.0, *)) {