jbsf / blindside

Blindside provides dependency injection capabilities for Objective-C on iOS and OS X
MIT License
71 stars 43 forks source link

Swift documentation doesn't mention the need to cast return value of `injector.instance` #59

Closed lalunamel closed 7 years ago

lalunamel commented 7 years ago

For example, in the Swift section there is a line

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

As someone new to Swift, that bit tripped me up.

akitchen commented 7 years ago

Thanks for the fix in #60