How to get Class object without instance?

foundation, ios, nsobject, objective-c, oop

Solution

Try with:

 if([aClass isSubclassOfClass:[UIViewController class]])

Problem

Is there any way to get the result of: ``` NSObject *a = [[NSObject alloc] init]; [a class]; ``` Without instantiating? I wish to pass Class object to function as argument, and check it then. Like this: ``` - (void) pushControllerOfClass: (Class) aClass { if([aClass isSubclassOfClass: *what should I write here?*]) { ... } } ``` Intuitively, I've tried to write ``` if([aClass isSubclassOfClass: UIViewController]) { ``` But it doesn't work. Thx for future response. Update: Is such a function considered bad in ObjectiveC? I've refactored code from Nahavandipoor's book iOS 5 Programming Cookbook. It was like that: ``` - (void) pushSecondController{ SecondViewController *secondController = [[SecondViewController alloc] initWithNibName:nil bundle:NULL]; [self.navigationController pushViewController:secondController animated:YES]; } ``` As for me, this is kind of bad function: It doesn't parametrized when it should be.

Original source