I have previously been able to get a full address String from a CLPlacemark using the following code for Swift 3:
let addressList = placemark.addressDictionary?["FormattedAddressLines"] as? [String]
let address = addressList!.joined(separator: "\n")
addressDictionary is now deprecated in swift 4.
I could extract each of the individual CLPlacemark address variable strings (name, country postalCode, etc) but I'm wondering if there is a simpler way to do it.
I know there is a postalAddress var which is of type CNPostalAddress but not sure how to convert that to a String.
You can get mailing address from CNPostalAddress
is like :
CNPostalAddressFormatter.string(from:YOUR_POSTAL_ADDRESS, style: .mailingAddress)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With