title: Swift 3 - Update key:value in dictionary in an array of dictionaries after comparison. Please assist
body: <p>I have an array of dictionaries that I get as a JSON response to a URL </p>
  
  <pre><code>JSONResponse1 = 
  [{"id":"100", "name":"Matt", "phone":"0404040404", "address":"TBC"}
  ,{"id":"110", "name":"Sean", "phone":"0404040404", "address":"TBC"}
  , {"id":"120", "name":"Luke", "phone":"0404040404", "address":"TBC"}]
  </code></pre>
  
  <p>I have another array of dictionaries that I get as a JSON response to another URL</p>
  
  <pre><code>JSONResponse2 = 
  [{"id":"100", "address":"1 Main Street"}
  , {"id":"120", "address":"3 Main Street"}]
  </code></pre>
  
  <p>Both these response are linked by the key "id". I want to compare JSONResponse2 against JSONResponse1, and update JSONResponse1 so as to show the addresses as well. So the output of JSONResponse1 becomes:</p>
  
  <pre><code>JSONResponse1 = 
  [{"id":"100", "name":"Matt", "phone":"0404040404", "address":"1 Main Street"}
  ,{"id":"110", "name":"Sean", "phone":"0404040404", "address":"TBC"}
  , {"id":"120", "name":"Luke", "phone":"0404040404", "address":"3 Main Street"}]
  </code></pre>
  
  <p><strong>Note that all "id"s are not always present in JSONResponse2, in that case I want to leave it as it is</strong></p>
  
  <p>Here is my attempt:</p>
  
  <pre><code>    for item in JSONResponse2.enumerated() {
          for var items in JSONresponse1 {
              if item.element["id"] == items["id"] {
                  let address_correct = item.element["address"] as! String
                  items["address"] = address_correct
  
                  self.finalDictionary.append(items)
  
              } else {
                  self.finalDictionary2.append(items)
              }
          }
      }
  </code></pre>
  
  <p>But this creates a really long finalDictionary2, because of for loop repetition. Any way around this?</p>