title: Where should I create a model instance for a view in SwiftUI?
body: <p>I am new to MVVM. As far as I understand, I must avoid using model code inside a view struct.</p>
  
  <p>In my case, I have 2 views, MainView and ChildView. MainView doesn't have a ViewModel. But ChildView has a ViewModel(e.g. ChildViewModel). Since the ChildViewModel is used only in ChildView, so I didn't register the model instance on EnvironmentObject or I didn't pass the instance to MainView, because MainView doesn't use the model at all.</p>
  
  <p>I think, the best way is that ChildView creates its own instance of the model by itself like below. But I am not sure whether it is ok or not. Does this break the rules of MVVM?</p>
  
  <pre><code>struct ChildView: View {
      @ObservedObject var childViewModel = ChildViewModel()
  
      var body: some View { ... }
  }
  </code></pre>
  
  <p>Thanks in advance.</p>