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
UIViewController4. - If the user working in
UIViewControllers 1,2,3 and 5 i want to update the data inUIViewController4 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
UIViewController4. - If the user currently in
UIViewController4 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);
Since you are working with a
UITabBarControlleryou can easily ask for the currently selected tab which should result in the active view controller. Try the methods:selectedViewController or
selectedIndex