title: Swift Async Alamofire return
body: <p>I'm getting an empty value on return annotations, I am sure this is because of the async scope, Ive tried everything to get</p>
  
  <pre><code> var annotations: [TestAnnotation] = []
  </code></pre>
  
  <p>to return the values but I can't. The loop is correctly appending the values within the makeRequest scope.</p>
  
  <pre><code>func makeRequest(url : String, params : [String : String]?, completionHandler: (responseObject: JSON?, error: NSError?) -&gt; ())  -&gt; Request? {
  
      return Alamofire.request(.GET, url, parameters: params, encoding: .URL)
          .responseString { request, response, responseBody, error in completionHandler(
              responseObject:
              {
                  // JSON to return
                  var json : JSON?
                  if let response = responseBody {
                      // Parse the response to NSData
                      if let data = (response as NSString).dataUsingEncoding(NSUTF8StringEncoding) {
                          json = JSON(data: data)
                      }
                  }
  
                  return json
  
                  }(), error: error)
      }
  }
  
  func annotations() -&gt; [TestAnnotation] {
      var annotations: [TestAnnotation] = []
  
      var points: NSDictionary = [:]
      self.makeRequest("http://192.168.0.10/test/globe.php", params: nil) { json, error in
  
          if let data = json!.rawData() {
              let json = JSON(data: data)
  
              for var i = 0; i &lt; json["venues"].count; i++
              {
                  let lat = (json["venues"][i]["latitude"]).doubleValue as CLLocationDegrees
                  let lon = (json["venues"][i]["longitude"]).doubleValue as CLLocationDegrees
                  let venuesid = (json["venues"][i]["id"]).stringValue as String
                  ///
                  let coordinate1 : CLLocationCoordinate2D = CLLocationCoordinate2DMake(lat, lon)
  
                  let a1: TestAnnotation = TestAnnotation(coordinate: coordinate1, title: glimpid)
                  annotations.append(a1)
  
              }
          }
  
      }
      return annotations
  
  }
  </code></pre>