Avatar
Avatar
tarunon
ChildView.delegateで循環参照が起きてますね delegateパターンを使うときは弱参照にするのはほぼ必須です SwiftUIではちょっと使いにくいと思うので、ハンドラパターンにすることが多いのではないかと思います
ありがとうございます。 ChildViewがParentVCを強参照しているということでしょうか? 弱参照がほぼ必須なdelegateパターンはstructでは使えないのですね。 ハンドラパターンとはこのような感じですかね。 class ParentViewController: UIViewController { override func viewDidLoad() { let childView = ChildView() { print("hoge") } } } struct ChildView: View { let closure: () -> Void }