I'm trying desperately with ForEach to only display what has the value true. No matter what I try, false is also displayed. The air is out now and I think it's so simple that I just don't see it. Here is a piece of code to which it should apply:
import SwiftUI
struct txt: Identifiable {
var id: Int
var text: String
var show: Bool
}
struct ContentView: View {
@State private var array = [
txt(id: 000, text: "True", show: true),
txt(id: 001, text: "True", show: true),
txt(id: 002, text: "True", show: true),
txt(id: 003, text: "False", show: false),
]
var body: some View {
NavigationView {
List {
ForEach(array.indices, id: \.self) { idx in
Text("\(self.array[idx].text)")
}
}
}
}
}