I have a problem with the function that I created, I want to return multiple values but seems like, I keep getting this error
Unexpected non-void return value in void function
func calculateDistance(_ firstLat: Double, _ firstLong: Double, _ secondLat: Double, _ secondLong: Double) -> (Double, Double, String) {
let URL = "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=\(firstLat),\(firstLong)&destinations=\(secondLat),\(secondLong)&key=KEYID"
Alamofire.request(URL)
.responseJSON { response in
if let value = response.result.value {
let json = JSON(value)
let distance = json["rows"][0]["elements"][0]["distance"]["value"].double! / 1000 // Double
let price = distance * 1.0 // Double
let duration = json["rows"][0]["elements"][0]["duration"]["text"] // String
return (distance, price, duration) // Keep getting this error on this line
}
}
}
What did I do wrong? I return the correct data type.