Get your own website
Demo.swift
ContentView.swift
App.swift
 
import SwiftUI

enum Route: Hashable { case number(Int), text(String) }

struct DestinationMultiDemo: View {
  @State private var path: [Route] = []
  var body: some View {
    NavigationStack(path: $path) {
      VStack(spacing: 12) {
        Button("Go to number 5") { path.append(.number(5)) }
        Button("Go to text 'Hello'") { path.append(.text("Hello")) }
      }
      .navigationDestination(for: Route.self) { r in
        switch r {
        case .number(let n): Text("Number: \(n)")
        case .text(let s): Text("Text: \(s)")
        }
      }
      .navigationTitle("Enum Destinations")
    }
  }
}

                    
import SwiftUI

struct ContentView: View {
  var body: some View { DestinationMultiDemo() }
}

                    
import SwiftUI

@main
struct MyApp: App {
  var body: some Scene { WindowGroup { ContentView() } }
}