title: Can functions be stored as fields? Is this a good approach for callbacks?
body: <p>I am looking for something where I can pass a function as a parameter in swift for my class.</p>
  
  <p>This is my current code.</p>
  
  <pre><code>import Foundation
  
  class StatusProgress{
      static var queue = "dispatch_get_main_queue" //which queue you want it to run under.
      static var priority = 0 //priority in the queue
      static var cancelCode = {}
      static var runCode = {}
  }
  </code></pre>
  
  <p>I'm not sure if this will work.  <strong>Is this the proper way to define that my class will take functions as part of its parameters?</strong> For example cancelCode and runCode are supposed to be functions that can be passed in to be ran.</p>
  
  <p>The doesn't seem to throw any errors.</p>
  
  <p>I'm doing this to make a progress class which will take arbitrary code and run it on a custom progress window.</p>
  
  <p>The alternative method to what I'm doing might be to make a property of this require a class that must adhere to a protocol possibly.  Not sure how that would work yet though.</p>