Here is a toy version of my problem:
class MainClass {
let toPass: ToPassProtocol
let otherClass: BbbProtocol
init(
toPass: ToPassProtocol,
otherClass: Bbb = Bbb(toPass: toPass)
) {
self.toPass = toPass
self.otherClass = otherClass
}
}
class Bbb: BbbProtocol {
let toPass: ToPassProtocol
init(toPass: ToPassProtocol) {
self.toPass = toPass
}
}
protocol ToPassProtocol {}
class ToPass: ToPassProtocol {}
protocol BbbProtocol {}
Which gives the error Cannot use instance member toPass as a default Parameter
So without using a function to pass ToPassProtocol after initialisation, how can I pass this class as, well, a parameter?