I have a tabBar with 4 tabs on it, and I want to perform some action when a specific tab is selected, so I have uncommented the UITabBarControllerDelegate in the xxAppDelegate.m
I also wanted to see the value that was being sent logged in the console - in order to test my "if" statement. However this is where I got stumped.
// Optional UITabBarControllerDelegate method
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
NSLog(@"%@", viewController);
}
The console dutifully logged any selected controller that had been selected, but in this particular format:
<MyViewController: 0x3b12950>
Now, I wasn't expecting the square brackets or the colon or the Hex. So my question is how do I format my IF statement? This is what I thought would work but I get an error mentioned further down.
// Optional UITabBarControllerDelegate method
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
NSLog(@"%@", viewController);
if (viewController == MyViewController)
{
//do something nice here …
};
}
... The error is "Expected expression before 'MyViewController'"
Anyone know how I should be doing this?