I have a screen for user input.
After the user fills in data the next screen appear, but "Number of Stands" tells me how many items are in my array.
It seems i need an array of an array? The "Number of Stands" on screen 1 dictates how many items are in array. i need my struct of "Stand" to display uniquely because in screen 2 i need the user to enter properties of each item in the array so i can perform a equation. Currently it just duplicates as i understand that but how do i separate each item in array to a self.id to be individual?
Here is my struct:
import Foundation
import SwiftUI
struct Stand: Codable, Identifiable, Hashable {
var id: String {
return self.stand
}
var stand: String
let area: String
let speed: Int
var rf: Int
}
Here is "Calculate Area screen" Code:
import SwiftUI
import Foundation
@Observable
class Stands {
var items = [Stand]()
}
struct Speeds1View: View {
let title: String
let productArea: String
let noStands: String
let billetArea: String
@Environment(\.dismiss) var dismiss
var standCount: Int {
let sc = Int(noStands) ?? 0
return sc
}
@State private var standArray = [Stand]()
@State var txtspeedCurrent: String
@State private var rF = ""
@State private var standNo: Int = 0
@State private var rFCalculated: Int = 0
@State private var stand = Stands()
var body: some View {
let arr = Array(1...standCount)
NavigationStack{
ZStack{
List{
ForEach(arr, id: \.self) { standCount in
StandRowView(stand: "\(standCount)", speedCurrent: $txtspeedCurrent, rfactor: "Area1/Area2")
}
}
}
}
}
}
I am sorry to bother anyone on here but if anyone can point me in the right direction on this I would appreciate it. Thank you.



