Reputation: 101
Getting the below error when using the NavigationStack in SwiftUI for Apple Watch platform.
NavitigationView works well but it does not serve the purpose.
Not sure what wrong is happening.
Any help would be appreciated.
Xcode: 15.4 Target: Apple Watch OS 10.4
<NavigationHostingControllerCache>: MISS at depth 0 in free stack
[NavigationHostingControllerCache_UIKit] <_TtGC7SwiftUI32NavigationStackHostingControllerVS_7AnyView_: 0x1540f200> containment skipped because source and destination were `nil`
<NavigationHostingControllerCache>: HIT at depth 0 in free stack
<NavigationHostingControllerCache>: MISS at depth 1 in free stack
<NavigationHostingControllerCache>: MISS at depth 2 in free stack
[NavigationHostingControllerCache_UIKit] <_TtGC7SwiftUI32NavigationStackHostingControllerVS_7AnyView_: 0x1540f200> containment skipped because sourceNavigationController and destination were equal Optional(<SwiftUI.UIKitNavigationController: 0x14c18200>)
[NavigationHostingControllerCache_UIKit] <_TtGC7SwiftUI32NavigationStackHostingControllerVS_7AnyView_: 0x15424400> containment skipped because sourceNavigationController or destination were nil
[NavigationHostingControllerCache_UIKit] <_TtGC7SwiftUI32NavigationStackHostingControllerVS_7AnyView_: 0x15432800> containment skipped because sourceNavigationController or destination were nil
Code:
import SwiftUI
@main
struct WearableBankingApp: App {
var body: some Scene {
WindowGroup {
ContentView1()
}
}
}
struct ContentView1: View {
@State var path = NavigationPath(["1", "2"])
var body: some View {
NavigationStack(path: $path) {
VStack {
NavigationLink("Go to int screen", value: "1")
}
.navigationDestination(for: String.self) { value in
Text("This is a string screen with value: \(value)")
}
}
}
}
Upvotes: 0
Views: 100
Reputation: 1319
Seems like the code below is probably more what you're going for?
struct ContentView1: View {
var destinations = ["1", "2"]
@State var path = NavigationPath()
var body: some View {
NavigationStack(path: $path) {
VStack {
ForEach(destinations) { value in
NavigationLink("Go to int screen", value: value)
}
}
.navigationDestination(for: String.self) { value in
Text("This is a string screen with value: \(value)")
}
}
}
}
Upvotes: -1