I have a view with a couple of subviews whose text is created using string interpolation with fields and function results from an observed object.
For example,
Where the class contains:
And in that class the array and selection members are @Published.
Many other views are using data from the observed object and displaying/updating correctly. It seems like SwiftUI somehow isn't figuring out that the strings are dependent upon the observed object, and I haven't been able to figure out a way to make it aware of this dependency (in SwiftUI 1.0... it looks like 2.0 might be adding an onChange modifier, but I cannot upgrade yet).
How can I get my views with interpolated strings to update properly?
For example,
Code Block Button("\(self.obj.get_value(self.obj.selection))") { self.obj.make_a_change(self.obj.selection) } NavigationLink(destination: MyFormView(self.obj)) { Text("\(self.obj.array[self.obj.selection])") }
Where the class contains:
Code Block @ObservedObject var obj : MyClass
And in that class the array and selection members are @Published.
Many other views are using data from the observed object and displaying/updating correctly. It seems like SwiftUI somehow isn't figuring out that the strings are dependent upon the observed object, and I haven't been able to figure out a way to make it aware of this dependency (in SwiftUI 1.0... it looks like 2.0 might be adding an onChange modifier, but I cannot upgrade yet).
How can I get my views with interpolated strings to update properly?