let controller = injector.getInstance(MyViewController.self)
which compiles, but doesn't allow you to use the variable controller because it is an unknown type.
In order for that variable to be recognized as an instance of MyViewController it should be
let controller = injector.getInstance(MyViewController.self) as! MyViewController
OR
let controller: MyViewController = injector.getInstance(MyViewController.self) as! MyViewController
For example, in the
Swift
section there is a linelet controller = injector.getInstance(MyViewController.self)
which compiles, but doesn't allow you to use the variable
controller
because it is an unknown type.In order for that variable to be recognized as an instance of
MyViewController
it should belet controller = injector.getInstance(MyViewController.self) as! MyViewController
ORlet controller: MyViewController = injector.getInstance(MyViewController.self) as! MyViewController
As someone new to Swift, that bit tripped me up.