struct ContentView: View { @State private var path: NavigationPath = .init() @State private var department: Department = .init() var body: some View { NavigationStack(path: $path) { Button("Visit Store") { let newStore: Store = .init() department.stores.append(newStore) path.append(newStore) } .navigationDestination(for: Store.self) { store in let storeIndex = department.stores.firstIndex { $0.id == store.id }! NavigationLink("See Item") {// navigationDestination(...)のネストではなくNavigationLinkを用いると問題ない let newItem: Item = .init() department.stores[storeIndex].items.append(newItem) let itemIndex = department.stores[storeIndex].items.firstIndex { $0.id == newItem.id }! return VStack { Text("price") TextField( "", value: $department.stores[storeIndex].items[itemIndex].price, format: .number ) .keyboardType(.decimalPad) } } } } } }
(edited)