I have a UITabBarController as part of my app delegate and I want to trap when the user touches a specific tab (the favourites) and force the table within it to reload the data.
What would be best practice in this instance?
I have added the UITabBarDelegate protocol to my app delegate and implemented the didSelectViewController method. So far so good. Within the method I get a viewController, so I can check its title, etc. to determine which tab is selected.
How can I then send a reloadData message to the UITableView in the viewController? I tried creating a method in my FavouritesViewController class and calling that but it does not work.
Example code:
#pragma mark UITabBarController delegate methods
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
// If the favourites tab is pressed then reload the data
if (viewController.title = @"Favourites")
{
if ([viewController respondsToSelector:@selector(reloadFavourites:)])
{
[viewController reloadFavourites];
}
}
}