Last active
March 22, 2018 21:45
-
-
Save garsdle/2769999e0a2cd6b909494f06fa13c8a7 to your computer and use it in GitHub Desktop.
Dependency Injection + protocol is magic
This file contains hidden or 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
protocol Helper { } | |
class BestHelper: Helper { /* I do the best helping in accordance to Helper */ } | |
class MockHelper: Helper { /* Fake it till you make it */ } | |
class MainClass { | |
let helper: Helper | |
init(helper: Helper) { | |
self.helper = helper | |
} | |
} | |
// let helper = BestHelper() | |
let helper = MockHelper() | |
let mainClass = MainClass(helper: helper) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment