title: How to merge Array of Structure in Swift
body: <pre><code>struct Message {
      var id: Int
      let referenceNumber : String
      let transactionNumber : String
      let transactionDate : String
  }
  
  struct Amount: Identifiable {
      var id: Int
      let value: Int
      let date: String
      var message = [Message]()
      }
  
  let messages : [Message] = [
      .init(id: 0, referenceNumber: &quot;RXX123&quot;, transactionNumber: &quot;TXX123&quot;, transactionDate: &quot;Jan/12/2021&quot;),
      .init(id: 1, referenceNumber: &quot;RXX124&quot;, transactionNumber: &quot;TXX124&quot;, transactionDate: &quot;Feb/12/2021&quot;),
      .init(id: 2, referenceNumber: &quot;RXX125&quot;, transactionNumber: &quot;TXX125&quot;, transactionDate: &quot;Jan/12/2021&quot;)
  ]
  
  var amounts: [Amount] = [
      .init(id: 0, value: 1000,date: &quot;Jan/12/2021&quot;),
      .init(id: 1, value: 2000,date: &quot;Feb/12/2021&quot;),
      .init(id: 2, value: 3000,date: &quot;Jan/12/2021&quot;)
  ]
  </code></pre>
  <p>How can I club both Arrays of Structure with identifier 'id' to form a working Dictionary so that it can be used into various views of the IOS app when someone taps on the Amount and it takes them to the next view which shows the relevant Message reference of TxnDate,RefNo etc.</p>
  <p>I am Using it Xcode project to make a presentation app</p>
  <pre><code>struct FrontView: View {
      init(){
          UITableView.appearance().backgroundColor = .clear
          UITableViewCell.appearance().backgroundColor = .clear
      }
      @State private var selections: String? = nil
      
      let messages : [Message] = [
      .init(id: 0, referenceNumber: &quot;RXX123&quot;, transactionNumber: &quot;TXX123&quot;, transactionDate: &quot;Jan/12/2021&quot;),
      .init(id: 1, referenceNumber: &quot;RXX124&quot;, transactionNumber: &quot;TXX124&quot;, transactionDate: &quot;Feb/12/2021&quot;),
      .init(id: 2, referenceNumber: &quot;RXX125&quot;, transactionNumber: &quot;TXX125&quot;, transactionDate: &quot;Jan/12/2021&quot;)
  ]
      
      var amounts: [Amount] = [
      .init(id: 0, value: 1000,date: &quot;Jan/12/2021&quot;),
      .init(id: 1, value: 2000,date: &quot;Feb/12/2021&quot;),
      .init(id: 2, value: 3000,date: &quot;Jan/12/2021&quot;)
  ]
      var body: some View{
          NavigationView{
              VStack(alignment: .center){
                  List{
                      ForEach(amounts){amount in
                          
                          NavigationLink(
                          destination: Text(amount.message),//not working
                          tag: &quot;&quot;,
                          selection: $selections) {UserRow(user: amount)}
                      }
                  }.background(DiamondBackground().edgesIgnoringSafeArea(.all))
                  
                  
              }
              
          }
          .navigationBarTitle(Text(&quot;Dynamic List&quot;))
      }
  }
  </code></pre>