title: How to get property of object from string swift
body: <p>I have below classs</p>
  
  <pre><code>class Appointment: NSObject {
  
        var id:NSString!
        var status:NSString!
  
        var clinic:Clinic!
        var medicalCase:MedicalCase!
        var patient:Patient!
  
        var appointmentDate:NSString!
        var reasonForVisit:NSString!
        var cancellationReason:NSString!
        var visit:NSString!
  
  }
  </code></pre>
  
  <p>And this code which parsing nsdisctionary and assigning value to Appointment object property</p>
  
  <pre><code>        if let appointments:NSArray! = topApps["apointments"] as? NSArray {
  
               dashboardRecord.apointments = NSMutableArray()
  
              for disc in appointments
              {
                  var appointment:Appointment! = Appointment()
                if let status: NSString! = disc["status"] as? NSString {
                      appointment.status = status
                  }
              }
  
          }
  </code></pre>
  
  <p>Now i want to do it dynamically. instead of doing like this </p>
  
  <pre><code>          if let status: NSString! = disc["status"] as? NSString {
                  appointment.status = status
              }
  </code></pre>
  
  <p>I want to do it dynamically, below code gives me values from disc without manually writing key but how to assign these values to appointment object properties. is there way to get object property from string?</p>
  
  <pre><code>           var properties = appointments.propertyNames()//giving me array of property names.
  
              for key in properties
              {
  
              }
  </code></pre>
  
  <p>want to do something like(just to explain what i want to achieve)</p>
  
  <p>appointment.["key"] = disc[key] // appointment is object of Appointment class </p>