I'm trying to build a ForEach()-Loop in SwiftUI for building UI-Elements, but I'm getting this error-message:
Unable to infer complex closure return type; add explicit type to disambiguate
Here is my code:
var body: some View {
HStack {
HStack {
VStack {
ForEach((1...10).reversed(), id: \.self) {
Text("\($0)")
Spacer()
}
Spacer()
}
Spacer()
}
Spacer()
}
}
The Error is pointing on the Line with the ForEach-Statement. I tried to follow the tutorial by Paul Hudson, see: https://www.hackingwithswift.com/quick-start/swiftui/how-to-create-views-in-a-loop-using-foreach