Inside the function the values are printed, but outside they are not. I need the values to come out of the function. I looked for a solution on this site but none of the ones I found worked.
let addressFull = (arrayServices?.address ?? "") + " - " + (arrayServices?.city ?? "")
let geocoder = CLGeocoder()
geocoder.geocodeAddressString(addressFull) {
placemarks, error in
let placemark = placemarks?.first
let lat = placemark?.location?.coordinate.latitude
let lon = placemark?.location?.coordinate.longitude
print("Lat 1: (String(describing: lat)), Lon 1: (String(describing: lon))")
// YES PRINT VALUE
}
print("Lat 2: (String(describing: lat)), Lon 2: (String(describing: lon))")
// PRINT NIL