In a meal planning app a user selects items they need for each day of the week which creates an array of items for each day. The arrays are then inserted into a shopping list array creating an Array of Arrays with all the items.
I'm stuck trying to show the combined list. In my code I am returning the count of arrays correctly, however when I try to display the items in each array I'm failing. Any help would be appreciated!
Here is a simplified example of what I'm trying to do:
import SwiftUI
struct ShoppingListView: View {
var shoppingList: Array<Array<String>>
var body: some View {
VStack(alignment: .leading) {
ForEach(0..<shoppingList.count, id: \.self) {list in
Text("number of arrays")
VStack {
List(0..<list) { item in
Text("item = \(item)")
}
}
}
}
}
}
struct ShoppingListView_Previews: PreviewProvider {
static var previews: some View {
let list = [["eggs", "bread", "milk", "cheese" ],["steak", "potatoes", "salad kit"]]
ShoppingListView(shoppingList: list)
}
}