Last active
September 7, 2016 17:17
-
-
Save chelseatroy/830ecc8417d37ddc4619fda41f240a24 to your computer and use it in GitHub Desktop.
ViewController Dependency Injection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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