0

I need to know my winow.rootviewcontroller name.

For example

    UITabBarController *demoTabBarController = [[UITabBarController alloc] init];
    [self.demoTabBarController setDelegate:self];
    self.demoTabBarController.viewControllers = [NSArray arrayWithObjects:mainNavController, searchView, challengeView, nil];
    self.window.rootViewController = self.demoTabBarController;

so in NSLog i want demoTabBarController as result. Is there any way i can achieve that?

Note that i dont want the class name of rootviewcontroller.

Jay Pandya
  • 507
  • 6
  • 26

2 Answers2

0

demoTabBarController is just the name of the pointer to your UITabBarController. It's not actually stored in memory.

You can get the class name using [self.window.rootViewController className] however this should return UITabBarController

Darren
  • 10,182
  • 20
  • 95
  • 162
0

Not directly. A pointer variable doesn't save any information about what other pointer variable gave it an object reference. If you need some kind of identification information about an object's history, you'll have to subclass UITabBarController and save what you want to display in your custom class.

(If you describe why you believe this is useful, someone might have another way to solve the more basic problem.)

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
  • Okay. so basically i have 3 sections in my project and each of this have different dedicated tabBarController i.e. A, B and C. A have 5 view A1, A2, A3, A4, A5. B have three views B1, B2, B3. C have 4 views C1, C2, C3, C4. according to the selection of the section that tabBarController come in act. And i also want to navigate to the previous tabBarController from new one. Is there any way i can achieve this. Please help me. – Jay Pandya Dec 12 '12 at 14:35
  • The only thing that comes to mind is to keep 3 properties that hold references to A, B, and C. Then you can compare the root controller's current address to each of those and log whatever you want based on the comparison. It's kind of what you asked for in your original question...just not as automatic. – Phillip Mills Dec 12 '12 at 14:41
  • Yes thats right. Thanks a lot for such positive response. I appreciate your help sir. – Jay Pandya Dec 12 '12 at 14:59