Hello Guys I want to combine two Arrays. One Int and one String, because I want to multiply the values of the Int Array.
Following is my code:
struct Zutaten: View{
@State var zutaten: [String]
@State var menge: [Int]
var body: some View{
HStack{
ForEach(zutaten, id: \.self) { Zutat in
Text(zutaten)
}
.multilineTextAlignment(.center)
.navigationBarHidden(true)
}
}
}
I want the output to be as followed: var menge var zutat, menge zutat, ....
Could you help me?
The whole Code is as Followed
struct Recipe: View {
@State var Eiweiß: Int = 23
@State var Kohlenhydrate: Int = 24
@State var Fett: Int = 13
@State var Calories: Int = 423
@State var Portionen: Int = 1
var body: some View {
ScrollView{
Image("Burger")
.resizable()
.frame(width: .infinity, height: 250)
.padding(.bottom, 10)
VStack {
PortionenAngabe(Portionen: $Portionen)
Werte(Eiweiß: $Eiweiß, Kohlenhydrate: $Kohlenhydrate, Fett: $Fett, Calories: $Calories, Portionen: $Portionen)
Zutaten(zutaten: ["Hack", "Mehl", "Brokkoli"], menge: [100, 200, 300])
}
}
.ignoresSafeArea(.all)
}
}
struct Zutaten: View{
@State var zutaten: [String]
@State var menge: [Int]
var body: some View{
HStack{
ForEach(zutaten, id: \.self) { Zutat in
Text(Zutat)
}
.multilineTextAlignment(.center)
.navigationBarHidden(true)
}
}
}