title: Completion handler for Alamofire network fetch
body: <p>I am attempting to create a function which will return a list of custom objects, created from parsing JSON. I am using AlamoFire to download the content. I have written this function which, on success, creates an array of locations to be returned. However, the returns are always nil. My code is below:   </p>
  
  <pre><code>func fetchLocations() -&gt; [Location]? {
      var locations : [Location]?
      Alamofire.request(.GET, myURL)
          .responseJSON { response in
              switch response.result {
               case .Success(let data):
                  locations = createMapLocations(data)
              case .Failure(let error):
                  print("Request failed with error: \(error)")
              }
          }
      return locations
  }
  </code></pre>
  
  <p>I am pretty positive the issue is that the functioning is returning before the network request is complete. I am new to Swift, and unsure how to handle this. Any help would be appreciated!</p>