title: How to wait until all NSOperations is finished?
body: <p>I have the following code: </p>
  
  <pre><code>func testFunc(completion: (Bool) -&gt; Void) {
      let queue = NSOperationQueue()
      queue.maxConcurrentOperationCount = 1
  
      for i in 1...3 {
          queue.addOperationWithBlock{
              Alamofire.request(.GET, "https://httpbin.org/get").responseJSON { response in
                  switch (response.result){
                  case .Failure:
                      print("error")
                      break;
                  case .Success:
                      print("i = \(i)")
                  }
              }
          }
          //queue.addOperationAfterLast(operation)
      }
      queue.waitUntilAllOperationsAreFinished()
      print("finished")
  }
  </code></pre>
  
  <p>and output is:</p>
  
  <pre><code>finished
  i = 3
  i = 1
  i = 2
  </code></pre>
  
  <p>but I expect the following:</p>
  
  <pre><code>i = 3
  i = 1
  i = 2
  finished
  </code></pre>
  
  <p>So, why queue.waitUntilAllOperationsAreFinished() don't wait?</p>