Kyle Decot
Kyle Decot

Reputation: 20825

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 annotation. What does this error mean & how can I avoid it?

Upvotes: 8

Views: 5167

Answers (3)

Munavar Pm
Munavar Pm

Reputation: 11

Actually this error of DEBUG:- ERROR The operation couldn’t be completed. (MKErrorDomain error 4.) I was solved when clear all recentApp's from simulator and re-run it.

Upvotes: 1

Jannik Arndt
Jannik Arndt

Reputation: 555

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".

Upvotes: 0

Ascendant
Ascendant

Reputation: 2579

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.

Upvotes: 4

Related Questions