Passing Data to ViewModal

class A {
    func processData {
   let viewModel: ViewModal = ViewModal()
    let viewController = ViewController()
    viewController.displayUI(viewModel)
      ....
....
....
....
    viewModel.imageName = "abcd"
    ....
....
....
....
    viewModel.imageName = "efg"
    ....
....
....
....
    viewModel.imageName = "hij"
    }
}

class ViewController {
  func displayUI (viewModal: ViewModal){
     let contentView = ContentView(viewModal: viewModal).environmentObject(self)
     // present contentView
  }
}

class ViewModal {
  @Published var imageName: String = ""
  @Published var label: String = ""

// string formatting
}

struct ContentView: View {
 @State var viewModel: ViewModal
 @EnvironmentObject var viewController: ViewController
 var body: some View {
 }
}

Can class A directly access ViewModal or it should pass the data to ViewController and ViewController set the data in ViewModal

Passing Data to ViewModal
 
 
Q