Skip to content

Instantly share code, notes, and snippets.

@ianterrell
Forked from mikelikespie/ConstructorExample1.swift
Last active June 16, 2016 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianterrell/c86aa1ad64453a214966ac81b31f75e9 to your computer and use it in GitHub Desktop.
Save ianterrell/c86aa1ad64453a214966ac81b31f75e9 to your computer and use it in GitHub Desktop.
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