Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading a random UIViewController?

I would like to pick a random UIViewController from a stored list of view controllers to load after one has finished. Yes, it needs to be a UIViewController and not just a UIView. I'm thinking I could do this with a .plist, but how would I go from the string name of a view controller to the actual view controller object name?

like image 452
Keller Avatar asked Dec 07 '25 12:12

Keller


1 Answers

To create an instance of a class from a name, you can use:

UIViewController* object = (UIViewController*)[[NSClassFromString(@"NameofClass") alloc] init];
like image 192
Eric Petroelje Avatar answered Dec 10 '25 02:12

Eric Petroelje