Hello there! I was trying to build an app with the new App feature in Swift Playgrounds for Mac. But I have an error message in my code, and I can't understand how to fix it. Can anyone help me to solve this error.
Here's the code:
import SwiftUI
struct Something: View {
let rows = 17
let columns = 17
let size: CGFloat = 10
let blocks: [[Color]] = [[.purple, .purple]]
var body: some View {
VStack {
ForEach((0...self.rows - 1), id: \.self) { row in
HStack (spacing: 0) {
ForEach((0...self.columns - 1), id: \.self) { col in
VStack (spacing: 0) {
Rectangle()
.frame(width: self.size, height: self.size)
.foregroundColor(self.blocks[row][col]) // index out of range: the requested index was outside the bounds of the array.
}
}
}
}
}
}
}