Could geocodeAddressDictionary in iOS 9 be implemented different from iOS 8

∥☆過路亽.° 提交于 2019-12-11 09:52:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!