CLLocationManager.location is nil

随声附和 提交于 2019-12-03 12:46:12

1) CLLocation location documentation - The value of this property is nil if no location data has ever been retrieved.

2) You've set the delegate for CLLocationManager. Why not implement locationManager:didUpdateLocations: and print the latest retrieved location from inside?

3) Are you using a simulator or a real device? Bear in mind that if you are using a simulator you may need to enable simulate location:

You can also find a Custom Location option in: - Simulator -> Debug -> Location -> Custom Location...

As of iOS 8 requestAlwaysAuthorization is ignored if you do not provide a string for NSLocationAlwaysUsageDescription in your Info.plist.

Link to documentation

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