I need an instance of root view controller.
I tried those approaches:
UIViewController *rootViewController = (UIViewController*)[[[UIApplication sharedApplication] keyWindow] rootViewController];
Returns: null:
Also when I try to get an array of controllers:
NSArray *viewControllers = self.navigationController.viewControllers;
It returns only one controller, but it isn't my root view controller.
If I try to take from navigation controller:
UIViewController *root = (UIViewController*)[self.navigationController.viewControllers objectAtIndex:0];
Returns: null:
Any ideas why? What else could I try to get an instance of my root view controller?
Thanks.