title: To wait in a loop (that backgrounds anyway) in Swift?
body: <p><strong>In Swift</strong> (that's Swift) there are a number of ways to handle asynchronous, </p>
  
  <p>Say you have a loop like this - it's calling a parse cloud code call <strong>which goes to background anyway</strong>.</p>
  
  <pre><code>public func runImages()
     {
     print("test begins...")
     for i in 1...3
        {
        print("Tick tock tick tock ..\(i)")
        PFCloud.callFunctionInBackground("blah", withParameters:["bla":i,"bla":"bla] )
           {
           (response: AnyObject?, error: NSError?) -&gt; Void in
            print(".. done! Now go again...")
            if let rr = response as? String { print(rr) }
            if let err = error { print(err.domain) }
           }
        }
     }
  </code></pre>
  
  <p>How to make that wait for the end of each PFCloud call?</p>
  
  <p>Really is just an ordinary flag best, or? (Note that (a) I can't get a flag to work in Swift and (b) as Paul points out you're blocking the UI!!)</p>
  
  <p>What is the "Swift way" <strong>in the context you see here</strong>?  I feel it would be very inelegant to use a recursive pattern here, for example.</p>