Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get UIViewController class name in iOS

I am getting viewControllers on navigationController stack as follows. Now I need to check if controller on top is one of known vc. How to get vc class name in order to compare it? Thank you.

NSArray *viewContrlls=[[self navController] viewControllers];
[viewContrlls lastObject]

something like,

if ([[viewContrlls lastObject] name] isEqualToString @"viewControllerName"){
like image 554
Jaume Avatar asked Nov 29 '12 10:11

Jaume


1 Answers

Use this It may Help's you

 NSString *CurrentSelectedCViewController = NSStringFromClass([[((UINavigationController *)viewController1) visibleViewController] class]);
like image 107
MadhuP Avatar answered Oct 12 '22 23:10

MadhuP