使用 swift 3 或 4 在 CLLocationManager 中不使用委托 didUpdateLocations 获取当前位置?

Get current location without using delegate didUpdateLocations in CLLocationManager using swift 3 or 4?

有没有使用 swift 3 或 4 而无需调用 CLLocationManager 中的委托 didUpdateLocations 来获取当前位置的方法?

您不会调用 didUpdateLocation: 而是调用 requestLocation(),它会更新用户位置然后调用 didUpdateLocation,但这不是重点...

“位置”实例 属性 可能是您正在寻找的,但正如文档所述,您不能保证它是最近的,您应该检查时间戳。

https://developer.apple.com/documentation/corelocation/cllocationmanager/1423687-location

您可以使用 mapView.userLocation.coordinate.

https://developer.apple.com/documentation/mapkit/mkmapview/1452459-userlocation