title: Swift dynamic property setting based on array keys
body: <p>I know a few questions already exist that seem to kinda cover what I'm asking (such as <a href="https://stackoverflow.com/questions/27366840/dynamically-set-properties-from-dictionarystring-any-in-swift">Dynamically set properties from Dictionary&lt;String, Any?&gt; in Swift</a>), but this doesn't seem to be quite what I'm looking for.</p>
  
  <p>Basically, I have a base object where I want to set the properties based on an object, like so:</p>
  
  <pre><code>init(data: Dictionary&lt;String,String&gt;)
  {
  
      for (key, value) in data
      {
          //TODO set property as value here?
      }
  }
  </code></pre>
  
  <p>I want to be able to pass a Dictionary in of keys/values and have them be dynamically added as properties of the object. I know that this behavior is possible in PHP, for example by doing <code>$this-&gt;{$key} = $value</code>, but I am somewhat unfamiliar with Swift so I haven't been able to figure out how to do this yet.</p>
  
  <p>Also, if anybody could tell me the name of the functionality I'm trying to achieve here, that'd be really helpful. Not knowing what this concept is called is making searching for answers difficult :c</p>