2
votes

I have a CLLocation manager. It works fine.

locManager = CLLocationManager()
locManager.delegate = self
locManager.desiredAccuracy = kCLLocationAccuracyBest
locManager.requestWhenInUseAuthorization()
locManager.startUpdatingLocation()

And of course, I have the delegate methods:

func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
        println("didfail")
        println(error)
    }

func locationManager(manager:CLLocationManager, didUpdateLocations locations:[AnyObject]) {
        println("location manager called..")
        let locationLast = locations.last as! CLLocation

        latitude = locationLast.coordinate.latitude.description
        longitude = locationLast.coordinate.longitude.description

        locManager.stopUpdatingLocation()

       //....
    }

There is no any problem it's working! But, when i'm here 47.5775679 19.0488392 (or at in 1-2km radius of this point ) it's throws this error:

Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

I was tried with simulator and real devices too. I have internet connection on the real devices when i was trying. Is there a black hole? :) or i don't know.

Could anybody please give me any idea about, what cause this phenomenon?

Thank you!

2
Did you try to run Maps app while at the same location? Does it show your location? Is accuracy good?Alex Pavlov

2 Answers

7
votes

This is happen when your device is not able find out your location from actual GPS system , wifi or internet. My observation is that when device(it was iPhone 4 for my case) is in a close room and connected with Wifi using hotspots from Laptop then most the time I am getting this same error.

Possible Solutions -

  1. If you got this error try to call locManager.stopUpdatingLocation() and again call locManager.startUpdatingLocation().

  2. Check your device having valid WIFI or 3G/2G Internet connection

  3. Go to settings and reset your location services

  4. Reset your network settings

Hope this will help you.

1
votes

This is an old question/answer but it does not consider the use case of the Simulator. That is, make sure that you do not have Debug > Location > None selected like so:

enter image description here

Be sure to select a valid location like Apple's HQ in Cupertino for instance:

enter image description here