UITabBarControllerDelegate compare value of viewController
Posted
by T9
on Stack Overflow
See other posts from Stack Overflow
or by T9
Published on 2010-05-01T23:27:38Z
Indexed on
2010/05/01
23:37 UTC
Read the original article
Hit count: 382
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?
© Stack Overflow or respective owner