/ConstructorExample1.swift Secret
Last active
June 16, 2016 20:27
-
-
Save ianterrell/c86aa1ad64453a214966ac81b31f75e9 to your computer and use it in GitHub Desktop.
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
protocol Service_A { | |
func doSomething() | |
} | |
protocol Service_B { | |
func doSomething() | |
} | |
protocol Service_C { | |
func doSomething() | |
} | |
protocol Service_D { | |
func doSomething() | |
} | |
class ViewController_A : ViewController { | |
let serviceA: Service_A | |
let serviceB: Service_B | |
let serviceC: Service_C | |
let serviceD: Service_D | |
init( | |
serviceA: Service_A, | |
serviceB: Service_B, | |
serviceC: Service_C, | |
serviceD: Service_D | |
) { | |
self.serviceA = serviceA | |
self.serviceB = serviceB | |
self.serviceC = serviceC | |
self.serviceD = serviceD | |
super.init() | |
} | |
func showNestedViewController() { | |
serviceA.doSomething() | |
presentViewController( | |
ViewController_B( | |
serviceB: serviceB, | |
serviceC: serviceC, | |
serviceD: serviceD | |
), | |
animated: true, | |
completion: nil | |
) | |
} | |
} | |
// Test code: | |
let testedVC = ViewController_A(serviceA: TestingServiceA(), serviceB: DummyServiceB(), | |
serviceC: DummyServiceC(), serviceD: DummyServiceD()) | |
/// now test testedVC for serviceA functionality ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment