SwiftData data propagation

My app application uses pure Swift, SwiftUI, & SwiftData. One view contains a quiz. After a user completes a quiz I would like to display the results in another separate view.

My specific problem is passing data to sibling views (from origin view to destination view). If anyone could help I would appreciate it.

I’m using

  1. @Model macro above my class
  2. .modelContainer for designing/ designating the container
  3. @Envioronment variable to insert the data into the context of the origin view.
  4. Add same data (quiz result) to destination view.

Accepted Reply

The quiz results should be in the model data, and the destination view should be based off that data. When the model data is updated you can trigger the visibility of the destination view by changing the tab index of your toolbar to show that view.

Replies

The quiz results should be in the model data, and the destination view should be based off that data. When the model data is updated you can trigger the visibility of the destination view by changing the tab index of your toolbar to show that view.