I am working on a project where I use CLGeocoder to determine the placemarks for a particular location.
Very simple call like this.
CLGeocoder().geocodeAddressString(location) { (placemarks, error) in
if let error = error {
print(error.localizedDescription)
}
Instead of printing out the NSError's localizedDescription, I would like to be able to capture the CLError code and respond accordingly. For example, if the location can't be found, my localizedDescription prints
The operation couldn’t be completed. (kCLErrorDomain error 8.)
How can I, in Swift determine the CLError code so that I do not have to switch on some localized description that will change based on user's locale?
Can this be done?
I only have a couple of cases that I want to switch on.
question from:
https://stackoverflow.com/questions/65837006/clgeocoder-geocodeaddressstring-error-codes 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…