Reputation: 496
Is there a way for me to determine the ViewController that was active when a user hits the Home button and the app delegate function applicationDidEnterBackground function is called?
Upvotes: 1
Views: 777
Reputation: 4277
So this line:
let vc: UIViewController = self.window!.rootViewController!
will give you the root view controller in Swift (assuming that you use that line in some method inside AppDelegate), but if you have containers (such as UITabBarController) -- you may need to go on that hierarchy for additional checks/inspections...
Upvotes: 1