Completion handler for Alamofire network fetch
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: func fetchLocations() -> [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