问题
I am looping through a set of addresses and performing a geocode on each one.
for aClient in passedPossible {
let geocoder = CLGeocoder()
let checkAddress = [
CNPostalAddressStreetKey:aClient[CNPostalAddressStreetKey]!,
CNPostalAddressCityKey:aClient[CNPostalAddressCityKey]!,
CNPostalAddressPostalCodeKey:aClient[CNPostalAddressPostalCodeKey]!,
CNPostalAddressCountryKey:"Australia"
]
geocoder.geocodeAddressDictionary(checkAddress, completionHandler: { (placemarks, error) -> Void in
// Etc do stuff...
}
In iOS 8.4 i am able to pass in 250 items, loop through and get a call back for each one.
But in iOS 9.0 with the same code it fails, giving me errors for all but about 40 items.
The error I get back is
Error Domain=kCLErrorDomain Code=2
I assume apple doesn't like me bulk geocoding ?
But why does it work in 8.4 and not now in 9.0
I guess I need to use mapQuest ?
Thanks for any input.
回答1:
iOS 9 might be more restrictive about this statement in the documentation:
Geocoding requests are rate-limited for each app, so making too many requests in a short period of time may cause some of the requests to fail. When the maximum rate is exceeded, the geocoder passes an error object with the value kCLErrorNetwork to your completion handler.
来源:https://stackoverflow.com/questions/32061298/could-geocodeaddressdictionary-in-ios-9-be-implemented-different-from-ios-8