iOS 8 - Can't get current location, Error Domain=kCLErrorDomain Code=0

别等时光非礼了梦想. 提交于 2019-12-05 14:42:28
TimeString

I guess maybe you need to read this thread first as it's largely overlapped.

Location Manager Error : (KCLErrorDomain error 0)

But anyway, I tested your code and got the same error as you reported. Then I change the simulation configuration. To be specific, in the simulator, I clicked Debug -> Location -> Custom Location... and enter a coordinate, and I can periodically receive location events (at a speed of every sample per second.) So maybe the problem is not from the code but from the simulator itself. Hope my answer helps.

UPDATE

I guess I misunderstood your question. What you want is to "automatically" get your current location in simulator. I'm afraid there's no such feature in xcode, instead, you need to use "add gpx file to project", which is even more work than using customized location. But I mean, if you've successfully got correct locations, why it bothers you to get the correct current location from the simulator, or alternative, maybe you can test on phone?

In iOS 8 you have to first take the permission from the user to access the location you cannot access the local as in iOS 7

if CLLocationManager.locationServicesEnabled() {
        if self.manager.respondsToSelector("requestWhenInUseAuthorization") {
            manager.requestWhenInUseAuthorization()
        } else {
            startUpdatingLocation()
        }
    }

for more take help from this link http://nshipster.com/core-location-in-ios-8/

Check Internet connection. if connection is ok then First Go to Xcode log bar and set "Dont simulate location". Then select simulator menu>debug>location>set custom or select any.

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