title: (UIApplication.shared.keyWindow?.rootViewController as? BaseSlidingController)?.openMenu() return nil Swift 4.2
body: <p>I have a problem with the above stated. I can not find the exact information on the forums. Most of them are outdated and I have written the code programmatically.  I have a controller that contains a view to edit the profile. I can not access that after changing the function listed below. I have a rootviewcontroller set to something else, but I tried the UiApplication calls anyway and it return nil and I can not open the profile controller. This is the function listed below. </p>
  
  <pre><code>@objc func handleOpen2() {
      (UIApplication.shared.keyWindow?.rootViewController as? BaseSlidingController)?.openMenu()
  }
  </code></pre>
  
  <p>Xcode does not give me an error but I can not get my menu to open. My rootviewcontroller is set to something else in app delegate. I have a controller that is used to control the sliding menu when I press the edit profile button. </p>
  
  <pre><code>    func openMenu() {
          isMenuOpened = true
          redViewLeadingConstraint.constant = menuWidth
          redViewTrailingConstraint.constant = menuWidth
          performAnimations()
          setNeedsStatusBarAppearanceUpdate()
      }
  </code></pre>
  
  <p>This code is used to open my side bar menu with the information I need and also to perform animations as well. I was wondering if someone had any idea what I can do different instead in my handleOpen2 function. If you need more code, please let me know. Thanks</p>