Geocoding and Regions
Convert coordinates to addresses and monitor regions.
What Is Geocoding?
Geocoding converts a human address into coordinates; reverse geocoding turns coordinates back into a readable address. Core Location provides CLGeocoder for both, talking to Apple's servers.
import CoreLocation
let geocoder = CLGeocoder()Forward Geocoding an Address
Call geocodeAddressString(_:) with a free-form address. The completion returns an array of CLPlacemark objects; take the first and read its location.
geocoder.geocodeAddressString("Eiffel Tower, Paris") { placemarks, error in
if let coord = placemarks?.first?.location?.coordinate {
print(coord.latitude, coord.longitude)
}
}