final class Parent: ObservableObject { @Published var child: Child init(child: Child) { self.child = child } } final class Child: ObservableObject { @Published var age: Int init(age: Int) { self.age = age } func haveBirthday() { age += 1 } } /FTUFE0CTFSWBCMF0CKFDU 3FQSPEVDFUIFJTTVFPG0CTFSWBCMF0CKFDU
@Observable final class Parent { var child: Child init(child: Child) { self.child = child } } @Observable final class Child { var age: Int init(age: Int) { self.age = age } func haveBirthday() { age += 1 } } /FTUFE!0CTFSWBCMF 8JMMUIFJTTVFCFSFQSPEVDFE
5IFJTTVFJTSFTPMWFE @Observable final class Parent { var child: Child init(child: Child) { self.child = child } } @Observable final class Child { var age: Int init(age: Int) { self.age = age } func haveBirthday() { age += 1 } } struct BirthdayView: View { @State var parent = Parent(child: Child(age: 1)) var body: some View { Text("child is \(parent.child.age) years old") Button("Have Birthday", action: { parent.child.haveBirthday() }) } } /FTUFE!0CTFSWBCMF