It was my mistake. I tried the solution before, but made a syntax error:
in .swipeActions
:
Button { editLesson(lesson: lesson) } label: { Label("Edit", systemImage: "pencil") }
the called function:
func editLesson(lesson: Lesson) { forEdit = lesson }
the sheet:
.sheet(item: $forEdit) { editLesson in NavigationStack { EditLesson(lesson: editLesson).environmentObject(realmService) } }
Now it works without any problems. I forgot editLesson
in inside the sheet syntax. Thank you for your comment.