How to define initializers in a protocol extension?
protocol Car { var wheels : Int { get set} init(wheels: Int) } extension Car { init(wheels: Int) { self.wheels = wheels } } on self.wheels = wheels i get the error Error: variable 'self' passed by reference before being initialized How can I define the initializer in the protocol extension? As you can see this doesn't work under these circumstances because when compiling, one has to make sure that all properties are initialized before using the struct/enum/class. You can make another initializer a requirement so the compiler knows that all properties are initialized: protocol Car { var wheels