title: Storing functions in an array, or alternative method
body: <p>I am writing a program in swift for iOS.  I have a node with several child nodes organized size by side.</p>
  
  <p>I have two different functions that change the position of these nodes.</p>
  
  <p>One moves the left node over to the right side, and the other moves all the nodes together towards a certain point (because one node was 'removed')</p>
  
  <p>The problem is that these calls are done asynchronously.  One is done with the rendering, the other is done after user interaction.  And so, when the user does an interaction AND there is a movement in the sliding node, they interfere with each other.</p>
  
  <p>My solution was to store both functions in an array and then call them in the 'update' event.  Each function 'locks' the node so that the other function won't be called until it is complete.</p>
  
  <p>My question is, how do I store and execute these functions in Swift.</p>
  
  <p>I have </p>
  
  <pre><code>var actionQueue:[(()-&gt;())]
  </code></pre>
  
  <p>in the head of my class.</p>
  
  <p>But how do I add the function? </p>
  
  <pre><code>actionQueue.append(shiftNodesTowards(position: CGPoint))
  </code></pre>
  
  <p>And how do I execute?</p>
  
  <pre><code>if !positionLock &amp;&amp; actionQueue.count &gt; 0 {
       var toDo = actionQueue.removeAtIndex(0)
  }
  </code></pre>
  
  <p>Thank you!</p>