I have this class and protocol in a framework:
public protocol P {}
open class C {
public init(_ p: P.Type) {
//super.init() etc
}
}
And in the project using this framework:
enum E: P {
// cases...
}
The thing that bugs me is that for every class that inherits C
, I need to define the same init()
like this:
final class C1: C {
init() {
super.init(E.self)
}
}
final class C2: C {
init() {
super.init(E.self)
}
}
// etc...
Is there a way for me to declare this default init
in my project, like using an extension this way:
extension C {
// Declare the init(E.self) here somehow?
}
This way, I would simply call C1()
, C2()
etc without defining it in the subclass.
Thanks for your help.