struct ContentView {
@ObservedObject var annotationsVM = AnnotationsVM()
//I'd like to pass in the ViewModel() declared below into annotationsVM like AnnotationsVM(VModel: Vmodel)
@ObservedObjects var VModel = ViewModel()
var body: some View {
//All the SwiftUI view setup is in here
}
}
class AnnotationsVM: ObservableObject {
@ObservedObject var VModel = ViewModel()
//I'd like to pass in the VModel in content view like: @ObservedObject var VModel: VModel
}
Obviously, I can't pass in the VModel directly upon ContentView creation like I want to because the VModel object hasn't been created yet so it's inaccessible...
Recap: I want to pass in the VModel instance declared in ContentView into the annotationsVM instance (also declare in ContentView)