title: How to make async / await in Swift?
body: <p>I would like to simulate async and await request from Javascript to Swift 4. I searched a lot on how to do it, and I thought I found the answer with <code>DispatchQueue</code>, but I don't understand how it works.</p>
  
  <p>I want to do a simple stuff:</p>
  
  <pre><code>if let items = result.value {
      var availableBornes = [MGLPointFeature]()
  
      for item in items {
          guard let id = item.id else { continue }
  
          let coordinate = CLLocationCoordinate2D(latitude: Double(coor.x), longitude: Double(coor.y))
  
          // ...
  
          // This is an asynchronous request I want to wait
          await _ = directions.calculate(options) { (waypoints, routes, error) in
              guard error == nil else {
                  print("Error calculating directions: \(error!)")
                  return
              }
  
              // ...
  
              if let route = routes?.first {
                  let distanceFormatter = LengthFormatter()
                  let formattedDistance = distanceFormatter.string(fromMeters: route.distance)
                  item.distance = formattedDistance
  
                  // Save feature
                  let feature = MGLPointFeature()
  
                  feature.attributes = [
                      "id": id,
                      "distance": formattedDistance
                  ]
  
                  availableBornes.append(feature)
  
              }
          }
      }
  
      // This should be called after waiting for the async requests
      self.addItemsToMap(availableBornes: availableBornes)
  }
  </code></pre>
  
  <p>What should I do?</p>