开发者

The operation couldn’t be completed. (MKErrorDomain error 4)

I am using the MKReverseGeocoder but I keep getting reverseGeocoder:didFailWithError: "The operation couldn’t be completed. (MKErrorDomain error 4.)". I am passing the geocoder the coordinates of the MKUserLocation annot开发者_如何学Pythonation. What does this error mean & how can I avoid it?


My answer to a similar question:

I've met and solved this issue recently. In my case, when Apple Map cannot find any result for a query, it sometimes will just throw this this "MKErrorDomain = 4" error. So I ended up just treating this as "result not found".

It was painstaking to find this out, MapKit needs a better Error handling system.


It's documented at https://developer.apple.com/documentation/mapkit/mkerror/code#topics.

If you look into the code of MKError, you find the enum:

public enum Code : UInt {

        
        public typealias _ErrorType = MKError

        case unknown = 1

        case serverFailure = 2

        case loadingThrottled = 3

        case placemarkNotFound = 4

        @available(iOS 7.0, *)
        case directionsNotFound = 5

        @available(iOS 13.0, *)
        case decodingFailed = 6
    }

So MKERRORDOMAIN error 4 just means "placemark not found".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜