Is there a way to get the current view controller from the AppDelegate? I know there is rootViewController, but that's not what I'm looking for.
See Question&Answers more detail:osIs there a way to get the current view controller from the AppDelegate? I know there is rootViewController, but that's not what I'm looking for.
See Question&Answers more detail:osIf your app's root view controller is a UINavigationController
you can do this:
((UINavigationController*)appDelegate.window.rootViewController).visibleViewController;
Similarly, if it's a UITabBarController
you can do this:
((UITabBarController*)appDelegate.window.rootViewController).selectedViewController;
Of course, explicit casting like this is dirty. Better would be to capture the reference yourself using strong types.