Does anyone know why the self.indexCount
in the ForEach
is giving the error Cannot use mutating getter on immutable value: 'self' is immutable
error? I can provide aView
with indexCount
, but it's not very convenient. I'm not changing indexCount. Is this a SwiftUI bug or intentional?
struct aView: View {
let array: [[String]]
lazy var indexCount: Int = array[0].count
var body: some View {
VStack {
ForEach(0..<self.indexCount, id: \.self) { index in
Text("Hello World")
}
}
}
}