0

I want to print a list of all of the app's viewcontrollers which are loaded in order to understand why am I getting a white screen and for general debugging purposes.

Please advise, Thanks, Asaf

1
  • is it coming with a white screen? Commented May 15, 2014 at 15:56

2 Answers 2

1

You can do some recursive printout like this (I know it's not perfect, but it's a start):

static void printViewControllerRecursively(UIViewController *viewController, NSUInteger level) { NSMutableString *spaces = [NSMutableString stringWithCapacity:level * 3]; for (NSUInteger i = 0; i < level; ++i) { [spaces appendString:@" "]; } NSLog(@"%@->%@", spaces, viewController); if ([viewController isKindOfClass:[UITabBarController class]]) { for (UIViewController *child in [(UITabBarController *)viewController viewControllers]) { printViewControllerRecursively(child, level + 1); } } else if ([viewController isKindOfClass:[UINavigationController class]]) { for (UIViewController *child in [(UINavigationController *)viewController viewControllers]) { printViewControllerRecursively(child, ++level); } } } 

Then just call printViewControllerRecursively([UIApplication sharedApplication].keyWindow.rootViewController, 0);

Sign up to request clarification or add additional context in comments.

Comments

0

This doesn't seem like a good way to try and debug anyhitng but that being said you can use:

NSLog(@"%@", [self.navigationController viewControllers]); 

or

NSLog(@"%@", [self.tabBarController viewControllers]); 

etc ...

Guess it depends on how you've setup your App.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.