title: Is it possible in Swift to execute code at runtime from a string?
body: <p>I have a list of items that have conditions associated with them. I want to store this list of items and their conditions in a plist rather than hardcode them into a .swift file.</p>
  
  <p>The only problem with that is that there needs to a function associated with each item to check a condition. Here is what it might look like hardcoded:</p>
  
  <pre><code>let myJobStep1 = JobStep(heading: "My Heading", description: "This is the description", warningText: "", condition_check: { () -&gt; Bool in
      return (self.trayColor == .Blue) || (self.trayColor == .Red)
  })
  
  let myJobStep2 = JobStep(heading: "My Heading", description: "Another description", warningText: "", condition_check: { () -&gt; Bool in
      return (self.trayColor == .Green)
  })
  </code></pre>
  
  <p>The question is how to encapsulate the function that is checking conditions in a string that can be in a plist file.</p>
  
  <p>Thanks!</p>