title: Swift 3 - set the key when appending to array
body: <p>I have this array where I set the keys on the creation. Now in some point in my view I load some more information based on ids (the keys). </p>
  
  <pre><code>var colors = [
      "37027" : UIColor(red:150/255, green:57/255, blue:103/255, alpha:1),
      "12183" : UIColor(red:234/255, green:234/255, blue:55/255, alpha:1),
      "44146" : UIColor(red:244/255, green:204/255, blue:204/255, alpha:1)
  ]
  </code></pre>
  
  <p>I want to add more colors to this array dynamically. How can I insert new items in the array setting the key? Something like</p>
  
  <pre><code>colors["25252"] = UIColor(red:244/255, green:204/255, blue:204/255, alpha:1)
  </code></pre>
  
  <p>The line above doesn't work, it is just to illustrate what I need.</p>
  
  <p>Thanks for any help</p>
  
  <p>Update: the code above is an example. Below the real code:</p>
  
  <pre><code>var placedBeacons : [BeaconStruct] = []
  
          BeaconModel.fetchBeaconsFromSqlite(completionHandler: {
              beacons in
  
              for item in beacons{
                  self.placedBeacons["\(item.major):\(item.minor)"] = item
              }
          })
  </code></pre>
  
  <p>Error: <code>Cannot subscript a value of type '[BeaconStruct]' with an index of type String</code></p>