I want to use a ForEach loop, but it doesn't work.
let navigation = [["Kunde", "person"], ["Wartung", "gear"]]
NavigationView {
List {
NavigationLink(destination: ListView(title: "Kunde")) {
Label("Kunde", systemImage: "person")
}
NavigationLink(destination: ListView(title: "Wartung")) {
Label("Wartung", systemImage: "gear")
}
// MANY MORE
}
}
My approach prints the numbers from 0 to 7, but I want the contents of the array.
My approach:
let navigation = [["Kunde", "person"], ["Wartung", "gear"]]
NavigationView {
List {
ForEach(navigation.indices) { index in
NavigationLink(destination: ListView(title: "\(index)")) {
Label("\(self.index)", systemImage: "\(index)")
}
}
}
}