title: Is it appropriate to create multiple ViewModels in one View?
body: <p>This is more of a code architecture question.</p>
  <p>I have a Game View with a deck of 52 cards. The model is:</p>
  <pre><code>struct Card {
      let suit: String
      let value: String
  }
  </code></pre>
  <p>The simplified ViewModel is:</p>
  <pre><code>class GameViewModel: ObservableObject {
      let numberOfCards: Int
      @Published var cards: [Card] = []
  
      init(numberOfCards: Int) {
          self.numberOfCards = numberOfCards
          for _ in 0..&lt;numberOfCards {
              cards.append(Card(suit: &quot;&quot;, value: &quot;&quot;))
          }
      }
  //Other logic methods
  }
  </code></pre>
  <p>And the View:</p>
  <pre><code>struct GameView: View {
      @StateObject var gameVM = GameViewModel(numberOfCards: 52)
  ...
  }
  </code></pre>
  <p>I've kept all game logic in GameViewModel, even manipulated cards via its <code>self.cards[i]</code>, but now I've realized that I will need more control over each Card and thus probably a ViewModel for each Card.</p>
  <p>Question: is creating 52 more ViewModels a good MVVM design pattern? Or one View = one ViewModel?</p>
  <p>And where should I create Cards ViewModels? In the View? Or GameViewModel should create them like:</p>
  <pre><code>class GameViewModel: ObservableObject {
      let numberOfCards: Int    
      @Published var cards: [CardViewModel] = []
  
      init(numberOfCards: Int) {
          self.numberOfCards = numberOfCards
          for _ in 0..&lt;numberOfCards {
              cards.append(CardViewModel(suit: &quot;&quot;, value: &quot;&quot;))
          }
      }
  }
  </code></pre>
  <p>P.S. I feel like this question can be expanded to any example where we have One-Many relations like CategoryVM-&gt;Items, or GroupVM-&gt;Individuals, or FamilyVM-&gt;People.</p>