Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ViewController Dependency Injection
public class ExampleViewController: UIViewController {
var dependableService: DependableService
@IBOutlet var someTextLabel: UITextLabel!
class func loadFromStoryboard(
dependableService: DependableService) -> ExampleViewController {
let controller = UIStoryboard(name:"Main", bundle:NSBundle(forClass:self))
.instantiateViewControllerWithIdentifier("ExampleViewController")
as! ExampleViewController
controller.dependableService = dependableService
return controller
}
required public init?(coder aDecoder: NSCoder) {
self.dependableService = AppEnvironment.sharedEnvironment.dependableService
super.init(coder:aDecoder)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.