Learn Courses My Dashboard

Passing Array Data to a separate view in SwiftUI

I’m creating an app with three views in SwiftUI;

  • ContentView
  • GameView
  • ResultsView

In the GameView I have declared an Array which I need to access in the ResultsView - how do I do this. I want to use the array data in the ResultView to undertake evaluations and manipulate data in an array created in ResultsView.

I’ve researched the site and found a couple of suggested methods (@environementobject, observableobject) - but this is all confusing to me…any tips?

You may need to implement MVVM architecture in your App.

Chris Ching has a course on CWC+ that shows how this is done. It may be an opportunity for you to subscribe to CWC+ which you can do so via this link.