Reputation: 2691
Take this line of code:
let controller = storyboard.instantiateInitialViewController() as! MyCustomTableViewController
Now I want to replace MyCustomTableViewController
by a variable, something like this:
var customTVC: UITableViewController
customTVC = MyCustomTableViewController
let controller = storyboard.instantiateInitialViewController() as! customTVC
The compiler complains with:
Cannot assign a value of type customTVC.Type to type UITableViewController in coercion
I get the message, but what is the way to do this properly? The obvious point is that the exact sort of subclass can vary and I want to implement that controller reference only once.
Upvotes: 1
Views: 88