0 Replies
      Latest reply on Aug 22, 2019 12:47 PM by thiezn
      thiezn Level 1 Level 1 (0 points)

        I have a class conforming to the @ObservableObject protocol and created a subclass from it with it's own variable with the @Published property wrapper to manage state.


        It seems that the @published property wrapper is ignored when using a subclass. Does anyone know if this is expected behaviour and if there is a workaround?


        I'm running iOS 13 Beta 8 and xCode Beta 6.


        Here is an example of what I'm seeing. When updating the TextField on ```MyTestObject``` the Text view is properly updated with the aString value. If I update the ```MyInheritedObject```TextField the anotherString value isn't updated in the Text view.


        import SwiftUI
        class MyTestObject: ObservableObject {
            @Published var aString: String = ""
        class MyInheritedObject: MyTestObject {
            @Published var anotherString: String = ""
        struct MyView: View {
            @ObservedObject var myTestObject = MyInheritedObject()
            @ObservedObject var myInheritedObject = MyInheritedObject()
            var body: some View {
                NavigationView {
                    VStack(alignment: .leading) {
                        TextField("Update aString", text: self.$myTestObject.aString)
                        Text("Value of aString is: \(self.myTestObject.aString)")
                        TextField("Update anotherString", text: self.$myInheritedObject.anotherString)
                        Text("Value of anotherString is: \(self.myInheritedObject.anotherString)")