Reputation: 5510
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?
Upvotes: 0
Views: 436
Reputation: 961
Mike's solution should have worked all right. Apparently, it is not able to understand what SearchViewController is, really. Can you check putting a forward declaration
@class SearchViewController
for the SearchViewController class in the header file of the class where the above code is written, and then importing the SearchViewController.h file in the source file of the class where the above code is written.
#import "SearchViewController.h"
Upvotes: 1