title: How to set multiple EnvironmentObjects which are same type
body: <p>I found this question <a href="https://stackoverflow.com/questions/56699418/swiftui-putting-multiple-bindableobjects-into-environment/56699552#56699552">SwiftUI: Putting multiple BindableObjects into Envionment</a></p>
  
  <p>the answer said environmentObject(ObservableObject) returns modified view, therefore I can make call chain for multiple environmentObject.</p>
  
  <p>like</p>
  
  <pre class="lang-swift prettyprint-override"><code>let rootView = ContentView()
       .environmentObject(firstBindable)
       .environmentObject(secondBindable)
  </code></pre>
  
  <p>and I wonder what is result if firstBindable and secondBindable are same type. how <code>.environmentObject()</code> knows what is exect value which is a programmer intended to set between <code>firstBindable</code> and <code>secondBindable</code>.</p>
  
  <p>so I tested this</p>
  
  <ol>
  <li>I made an ObservableObject class</li>
  </ol>
  
  <pre class="lang-swift prettyprint-override"><code>final class TempStr: ObservableObject {
      @Published var tmpStr = "temp"
  
      init(initStr: String) {
          tmpStr = initStr
      }
  }
  </code></pre>
  
  <ol start="2">
  <li>made call chain of environmentObject from sceneDelegate</li>
  </ol>
  
  <pre><code>window.rootViewController
    = UIHostingController(rootView:
        TestView()
          .environmentObject(TempStr(initStr: "1st")) 
          .environmentObject(TempStr(initStr: "2nd"))
  </code></pre>
  
  <ol start="3">
  <li>and used values from View</li>
  </ol>
  
  <pre><code>struct TestView: View {
    @EnvironmentObject var tmp1: TempStr
    @EnvironmentObject var tmp2: TempStr
  
     var body: some View {
        Text(tmp1.tmpStr + " " + tmp2.tmpStr)
     }
  }
  </code></pre>
  
  <ol start="4">
  <li>result was '1st 1st'</li>
  </ol>
  
  <p>And if my code calls one .environmentObject() like</p>
  
  <pre><code>TestView().environmentObject(TempStr(initStr: "1st")) 
  </code></pre>
  
  <p>both tmp1 and tmp2 from TestView have same value <code>TempStr(initStr: "1st")</code>. it looks like <code>.environmentObject()</code> call sets all values of same type.</p>
  
  <p><br></p>
  
  <p>Actually, I knew that it couldn't work but I just tried it for using this question.</p>
  
  <p>I wonder what is correct way of achieving my goal.</p>
  
  <p>Thanks</p>