In Object-C I store Class objects in an array and init them dynamically like this:
self.controllers=@[[OneViewController class],[TwoViewController class]];
Class clz = self.controllers[index];
UIViewController *detailViewController = [[clz alloc] init];
In Swift i try this way but it raises an error:
var controllers:AnyClass[] = [OneViewController.self,TwoViewController.self]
var clz : AnyClass = controllers[index]
var instance = clz() // Error:'AnyObject' is not constructible with ()
I wonder Whether there is a way to convert AnyClass to a specific Class? Or any other good ideas?