title: Wait for Asynchronous Operations in Objective-C
body: <p>I'm googling like crazy and still confused about this. </p>
  
  <p>I want to download an array of file urls to disk, and I want to update my view based on the bytes loaded of each file as they download. I already have something that will download a file, and report progress and completion via blocks. </p>
  
  <p>How can I do this for each file in the array?</p>
  
  <p>I'm ok doing them one at a time. I can calculate the total progress easily that way: </p>
  
  <pre><code>float progress = (numCompletedFiles + (currentDownloadedBytes / currentTotalBytes)) / totalFiles)
  </code></pre>
  
  <p>I mostly understand GCD and NSOperations, but how can you tell an operation or dispatch_async block to wait until a callback is called before being done? It seems possible by overriding NSOperation, but that seems like overkill. Is there another way? Is it possible with just GCD?</p>