Skip to content

Instantly share code, notes, and snippets.

@ileitch
Last active May 9, 2018 06:17
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 ileitch/82422913a3d0492e006ae6c6fc36a434 to your computer and use it in GitHub Desktop.
Save ileitch/82422913a3d0492e006ae6c6fc36a434 to your computer and use it in GitHub Desktop.
protocol Injectable {
init()
}
class MyDependency {}
class MyClass: Injectable {
private let dep: MyDependency
required convenience init() {
self.init(dep: MyDependency())
}
init(dep: MyDependency) {
self.dep = dep
}
}
class MyClass2: MyClass {
private let dep2: MyDependency
required convenience init() {
self.init(dep: MyDependency(), dep2: MyDependency())
}
init(dep: MyDependency, dep2: MyDependency) {
self.dep2 = dep2
super.init(dep: dep)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment