Navigate from List to Detail in SwiftUI and CoreData

I would like to do a NavigationLink from List to a Detail-
View (change the Stock-Datails). I know how to do the NavigationLink but not how to hand over the detail-Record of the list.



I would appriciate to see a sample. Those e.g. of "Landmarks" do not have Core-Date.
Thank you in advance
Answered by Apfelgruen in 656351022
I still could not solve my problem of "navigating" from list to a "ChangeEntity.swift". Even the famous "Bookworm" from "Hacking with Swift" only leads to a display of the data. So no change there either.

Has anyone ever "changed" CoreData at all? Adding and listing of Data works well.

Please: if someone has a solution, write me.

many thanks in advance.



Code Block struct StockList: View {
    
    @Environment(\.managedObjectContext) private var viewContext
    
    @FetchRequest(
        sortDescriptors: [NSSortDescriptor(keyPath: \Stock.bezeichnung, ascending: true)],
        animation: .default)
    
    private var waren: FetchedResults<Stock>
    
    var body: some View {
        NavigationView {
            List {
                ForEach(waren) { ware in
     //              <within a well doing List, it is not possible to send a Textfield to Screen always:>
// <Error: Cannot convert value of type 'String' to expected argument type 'Binding<String>'
                    TextField("bezi", text: ware.bezeichnung!)
                    
                    NavigationLink(
                        destination: StockAendern(ware: ware))
                    {
                        VStack(alignment: .leading) {
                            Text("\(ware.bezeichnung!) in \(ware.mengenEinheit!)")
                            HStack {
                                Text(.....


May be the 1. sample does not show enough. here is the data-model



Accepted Answer
I still could not solve my problem of "navigating" from list to a "ChangeEntity.swift". Even the famous "Bookworm" from "Hacking with Swift" only leads to a display of the data. So no change there either.

Has anyone ever "changed" CoreData at all? Adding and listing of Data works well.

Please: if someone has a solution, write me.

many thanks in advance.



Code Block struct StockList: View {
    
    @Environment(\.managedObjectContext) private var viewContext
    
    @FetchRequest(
        sortDescriptors: [NSSortDescriptor(keyPath: \Stock.bezeichnung, ascending: true)],
        animation: .default)
    
    private var waren: FetchedResults<Stock>
    
    var body: some View {
        NavigationView {
            List {
                ForEach(waren) { ware in
     //              <within a well doing List, it is not possible to send a Textfield to Screen always:>
// <Error: Cannot convert value of type 'String' to expected argument type 'Binding<String>'
                    TextField("bezi", text: ware.bezeichnung!)
                    
                    NavigationLink(
                        destination: StockAendern(ware: ware))
                    {
                        VStack(alignment: .leading) {
                            Text("\(ware.bezeichnung!) in \(ware.mengenEinheit!)")
                            HStack {
                                Text(.....


Navigate from List to Detail in SwiftUI and CoreData
 
 
Q