title: Swift Async With Completion Block
body: <p>I have two functions that executes async.</p>
  
  <p>I tried to "syncronize" them with: DispatchGroup and DispatchQueue</p>
  
  <pre><code>let queue = DispatchQueue(label: "com.company.app.queue", attributes: .concurrent)
  let group = DispatchGroup()
  
  queue.async(group: group) {
      //func1
  }
  
  queue.async(group: group) {
      //func2
  }
  
  group.notify(queue: queue) {
      print("#3 finished")
  }
  </code></pre>
  
  <p>Func1 and Func2 are only calls of: </p>
  
  <pre><code>class func getDataFromUrl( url: URL, completion: @escaping ( Data?, URLResponse?, Error? ) -&gt; ( ) )
      {
          URLSession.shared.dataTask( with: url )
          {
              data, response, error in
  
              completion( data, response, error )
          }.resume( )
      }
  </code></pre>
  
  <p>But the problem is that i do not know how to wait for the completion block in the queue.async ..</p>
  
  <p>Anyone has any ideea?</p>