Posts

Post not yet marked as solved
0 Replies
319 Views
I tried to use navigationstack, and it works. but couldn't print the path, and with the message: " NavigationPath(_items: SwiftUI.NavigationPath.(unknown context at $7ff84b690a28).Representation.eager([SwiftUI.(unknown context at $7ff84b6907f0).CodableItemBox<Swift.String>]), subsequentItems: [], iterationIndex: 0). " `import SwiftUI var toDos: [String] = [ "list1", "list2", "list3" ] struct ContentView: View { @State private var path = NavigationPath() var body: some View { NavigationStack(path: $path) { List { ForEach(toDos, id:\.self) { toDo in Button(action: { path.append(toDo) print(path) }, label: { Text("go to " + toDo) }) } } .navigationDestination(for: String.self) { toDo in Text("page for " + toDo) } } } } #Preview { ContentView() }` I tried navigationlink and simulator still works fine, but cannot print anything of path
Posted
by hyltlyy.
Last updated
.