In Objective-C, I can easily do this use the following codes:
- (instancetype)init {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
self = [sb instantiateViewControllerWithIdentifier:@"WMViewController"];
return self;
}
How can I implement this using Swift? I know it is strange to do this, but for some reasons, I must init a viewController like the following:
let vcClass = WMTableViewController.self
// ...
let vc = vcClass.init()
So in order to support storybord / xib
, it will be easy if can override init method and return another instance.
Here is the work I am doing:
I am trying to convert my little lib (WMPageController) to Swift (WMPageController-Swift), then I am stucked here.I would be happy if you have another suggestion or solution to deal with it.
Thanks a lot if you would like to help me.