PromiseKit / CoreLocation

Promises for Swift & ObjC
http://promisekit.org
MIT License
30 stars 29 forks source link

Apple docs say you should just ignore this error #24

Closed MrFuFuFu closed 5 years ago

MrFuFuFu commented 5 years ago

Hi there,

When I tried to get current location in my Simulator. Surely, it will gets wrong if Simulator doesn't have current location. So it will jump into this function and then runs into the if condition. I see the note. Could you explain that // Apple docs say you should just ignore this error? Or could you provide where the Apple docs says that? I didn't find it in CLError.locationUnknown.

Because the Promise didn't get rejected if the code run into this if condition in my Simulator.

Many thanks.

    @objc func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
        let (domain, code) = { ($0.domain, $0.code) }(error as NSError)
        if code == CLError.locationUnknown.rawValue && domain == kCLErrorDomain {
            // Apple docs say you should just ignore this error
        } else {
            seal.reject(error)
        }
    }

By the way, I chose the location as City Run or City Bicycle Ride or Freeway Drive in Simulator's Debug

mxcl commented 5 years ago

https://developer.apple.com/documentation/corelocation/cllocationmanagerdelegate/1423786-locationmanager?language=objc

This error tends to happen in the simulator and it means you have not set the simulator to provide a location.

MrFuFuFu commented 5 years ago

Cool, Thanks mate.

mxcl commented 5 years ago

Thanks 👍🏻

If you found my work helpful, please consider supporting its development.