Convert Multiple Addresses to Coordinates in Swift - IOS

Viewed 238

I used this to be able to view one address at a time. Convert address to coordinates swift

However, I would like to view an array of addresses (131) and their respective coordinates

Here is my code:

func convertAddressToCoordinates() {
    for address in addresses {
        geocoder.geocodeAddressString(address) { placemarks, error in
            let placemark = placemarks?.first
            let lat = placemark?.location!.coordinate.latitude
            let lon = placemark?.location!.coordinate.longitude
            print("\(address): Lat: \(lat!), Lon: \(lon!)")
        }
    }
}

As you can see, it grabs the placemarks first coordinate; anyway to grab all placemarks?

0 Answers
Related