I am trying to figure out which UIViewController is currently on the top of the UINavigationController stack, I am passing these values over to my NSArray viewCtrls, when I log the top UIViewController I get this.
<SearchViewController: 0x1457c550>
So this is the code I am trying to use to figure out which UIViewController is at the top of the UINavigationStack
NSArray *viewCtrls = navcontroller.viewControllers;
UIViewController *vCtrl = [viewCtrls objectAtIndex:[viewCtrls count]-1];
NSLog(@"%@", vCtrl);
if ([vCtrl isKindOfClass:SearchViewController]) {
NSLog(@"yes");
} else {
NSLog(@"no");
}
However I am getting this error on the first line of the if
statement.
Use of undeclared identifier 'SearchViewController'
I would like to know how I am supposed to declare the identifier? this is being called from a NSObjectClass, so I need to pass a parameter of self from the UIViewController that called this NSObjec class? or is there a better way of doing it?
You want [vCtrl isKindOfClass:[SearchViewController class]]