title: Using Reflection to Change Properties in Swift
body: <p>I am attempting to create a serializer that will change the properties of an object.</p>
  
  <p>Example:</p>
  
  <pre><code>class testobj{
      var prop1:Int = 3
      var prop2:String = "Hello"
      var prop3:Dictionary&lt;String,String&gt; = Dictionary&lt;String,String&gt;()
  }
  </code></pre>
  
  <p>I know I can access the names and types of the properties using</p>
  
  <pre><code>reflect(testobjc())[0].1
  </code></pre>
  
  <p>and</p>
  
  <pre><code>var tester = testobj()
  _std_lib_DemangledTypeName(tester.prop1)
  </code></pre>
  
  <p>but what I would like to do is something like</p>
  
  <pre><code>var tester = testobj()
  for(var x:Int = 0; x &lt; reflect(testobj()).count; x++){
      if(_std_lib_DemangledTypeName(tester.(reflect(testobj())[0].1)) == "Swift.String"){
          tester.(reflect(testobj())[0].1) = "World!"
      }
  }
  </code></pre>
  
  <p>Essentially, I want to loop through all the properties listed for a given class and set the properties on a newly created object of that class. Any guidance would be appreciated. Swift reflection is new to me.</p>