Post not yet marked as solved
Post marked as unsolved with 5 replies, 1,362 views
does anyone know why when i create an instance of a view by typing it names and then putting parentheses after it, in a for loop, the View shares data amongst the instances? i need unique values within an instanceHere's the code to my view:struct SwiftUIView: SwiftUI.View {
private let currentDB: [my_Section] = loadDB()
private let subcurrentDB: [my_subSection] = loadSubsubsections()
@ObservedObject var first_value: section_array
// @Binding var current_section: ContentView.my_Section
// @State private var comment: String = String()
var body: some SwiftUI.View {
Picker(selection: $first_value.first_value, label: Text("Subsection")) {
ForEach(0 ..< self.subcurrentDB.count) {
Text(self.subcurrentDB[$0].details)
}
}
}
}Here's how I create the view... ForEach(master_subsections) { result in
SwiftUIView(first_value: self.first_value)
}