I have this code but it开发者_开发问答 returns "nil" instead of a new class. Here it is useless but in my programme it makes sens.
Class myClass = [SettingsTableViewController class];
UIViewController *targetViewController = [[myClass alloc] initWithNibName:nil bundle:nil];
[[self navigationController] pushViewController:targetViewController animated:YES];
You are forgetting something or you might don't know. Here is the proper code.
Class myClass = NSCLassFromString(@"yourClassName");
if(myClass){
myClass = [[yourclassName alloc] init];
}
精彩评论