I am trying to check (using the XCTest framework) the view controllers that are inside the frame (dynamic library). I am having a problem with the UIApplication.sharedApplication () property. KeyWindow, which is zero. I have the following code:
override func setUp() {
super.setUp()
let storyboard = UIStoryboard(name: STORYBOARD_NAME_REPORT,
bundle: BundleUtil.getCurrentBundle())
let chatViewController = storyboard.instantiateViewControllerWithIdentifier(VIEW_CONTROLLER_ID_TIP_CHAT) as UIViewController
let navigationController = UINavigationController()
let viewControllers = [chatViewController]
navigationController.viewControllers = viewControllers
UIApplication.sharedApplication().keyWindow!.rootViewController = chatViewController
let _ = navigationController.view
let _ = chatViewController.view
}
Any ideas on how to properly initialize the keywindow property?
source
share