I'm trying to create a grid view in swiftui and it's not working out for me. Can someone tell me what I'm doing wrong? I tried using a c style for loop where I can set a variable and increment it, but swiftui throws an error when I do that.
struct ProductSubCat: View {
@State var productCategory = String()
@State var number = Int()
@ObservedObject var allData = WebserviceGetDataSolutions()
@State var theCount = 0
var body: some View {
ScrollView {
Spacer()
ForEach(0 ..< self.allData.posts[self.number].productLines.count / 2, id: \.self) {row in
HStack {
ForEach(0..<2) {cell in
NavigationLink(destination: ProductDetails())
{
Text(self.allData.posts[self.number].productLines[row].system)
Image("stonclad")
.resizable()
.aspectRatio(contentMode: .fit)
}.buttonStyle(PlainButtonStyle())
}
}
}
}
}
}