How to pass a local function to another object during init?
I did the below, but got \'self\' captured by a closure before all members were initialized
You have to call super.init()
before:
class ContextViewController: UIHostingController {
let drawViewWrapper: ContentView?
init(drawView: CustomDrawView) {
super.init(rootView: self.drawViewWrapper)
self.drawViewWrapper = ContentView(
drawView: drawView,
dismiss: { self.dismiss(animated: true) })
}
}