I have a variable var window: UIWindow? in AppDelegate.swift file inside class AppDelegate that I want to use in other class xyz.swift file inside class xyz as explained in here Get current view controller from the app delegate (modal is possible) but I am getting error at the first line any help will be appreciated. here is the code from xyz.swift 
func CurrentView() -> UIView
  {
     let navigationController = window?.rootViewController as? UINavigationController // Use of Unresolved identifier 'window'
     if let activeController = navigationController!.visibleViewController {
     if activeController.isKindOfClass( MyViewController )  {
       println("I have found my controller!")
          }
      }
  }
Even if I use let navigationController = AppDelegate.window?.rootViewController as? UINavigationController error is  'AppDelegate.Type' does not have member named 'window'
 
     
     
    