0

I am working in tabBar based iPhone app.

  • I have 5 UIViewControllers in tabbar controller.
  • In my application I have used APNS. When APNS received I want to update data in UIViewController 4.
  • If the user working in UIViewControllers 1,2,3 and 5 i want to update the data in UIViewController 4 and show badges.
  • I refresh and updated the data in UIViewController 4 but I want to show the badge if the user not in the UIViewController 4.
  • If the user currently in UIViewController 4 i don't want to show the badges.

How can i find another one UIViewController is in active or inactive from some other UIViewController?

Edit

I have tried below code to get the selectedIndex of UITabBarController.

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"%d", appDelegate.tabBarController.selectedIndex);
Gopinath
  • 5,392
  • 21
  • 64
  • 97

1 Answers1

1

Since you are working with a UITabBarController you can easily ask for the currently selected tab which should result in the active view controller. Try the methods: selectedViewController or selectedIndex

anka
  • 3,817
  • 1
  • 30
  • 36
  • Thanks for your reference. I have tried to get the selectedIndex but the value of selectedIndex not updating. It returning previous selected tab index. Could you please advice me? Thanks. – Gopinath Aug 14 '12 at 13:40