The code below is in my var body: some View {. When I run this, the app builds and runs exactly how I want. The problem is, if I remove one of the commented rows I get "Extra argument in call", and if I remove the comment for both I get the error "Extra arguments at positions #11, #12 in call". I really only need to call it 11 times, I only tried the 12 to see if the error was limited to 10 or just the last value.
Why would this work calling BarView() 10 times but not 11 or 12? I have tried to put this into a 1...10 loop instead but also could not figure out how to get that to work.
I am using xCode 12.2. I have been able to find a lot of people with the same error I get, but none of them are for the same reason so I have been unable to diagnose on my own. I really only build apps for fun and often stumble through the process and I'm just really stuck on this so any help would be really appreciated. Thanks.
HStack{
BarView(barGradeValue: 0, barSendValue: 10, barFlashValue: 10)
BarView(barGradeValue: 1, barSendValue: 20, barFlashValue: 10)
BarView(barGradeValue: 2, barSendValue: 30, barFlashValue: 10)
BarView(barGradeValue: 3, barSendValue: 40, barFlashValue: 10)
BarView(barGradeValue: 4, barSendValue: 50, barFlashValue: 10)
BarView(barGradeValue: 5, barSendValue: 60, barFlashValue: 10)
BarView(barGradeValue: 6, barSendValue: 50, barFlashValue: 10)
BarView(barGradeValue: 7, barSendValue: 40, barFlashValue: 10)
BarView(barGradeValue: 8, barSendValue: 30, barFlashValue: 10)
BarView(barGradeValue: 9, barSendValue: 20, barFlashValue: 10)
//BarView(barGradeValue: 10, barSendValue: 10, barFlashValue: 10)
//BarView(barGradeValue: 10, barSendValue: 10, barFlashValue: 10)
}
Then to show what this is calling, BarView() is the code below. Again, it works just how I want when I call it 10 times, just not more than that.
struct BarView: View {
var barGradeValue: Int
var barSendValue: CGFloat
var barFlashValue: CGFloat
//reference to main struct above
var content = ContentView()
var body: some View {
VStack {
Text(content.gradesV[barGradeValue])
ZStack (alignment: .top){
//Full height
Capsule().frame(width: 20, height: 100)
.foregroundColor(Color.gray)
//Flash Value
Capsule().frame(width: 20, height: barSendValue+barFlashValue)
.foregroundColor(Color.yellow)
//Send Value
Capsule().frame(width: 20, height: barSendValue)
.foregroundColor(content.gradesColor[barGradeValue])
}
}
}
}