【发布时间】:2022-09-23 05:44:23
【问题描述】:
我正在学习 KMM。我现在正在 iOSMain 和 Android main 中设计一个通用的位置获取
我的问题是,我不知道在 iOSMain 中将 Swift 映射到 Kotlin
例如,
获取位置的 Swift 代码是
var locationManager = CLLocationManager()
locationManager.requestWhenInUseAuthorization()
var currentLoc: CLLocation!
if(CLLocationManager.authorizationStatus() == .authorizedWhenInUse ||
CLLocationManager.authorizationStatus() == .authorizedAlways) {
currentLoc = locationManager.location
print(currentLoc.coordinate.latitude)
print(currentLoc.coordinate.longitude)
}
Kotlin 端实现:
在上面的代码中:
-
如何在 Kotlin 代码中使用 Swift 的
.authorizedWhenInUse和.authorizedAlways? -
而在
currentLoc.coordinate.longitude,longitude和latitude没有解决。为什么 ?请帮我
标签: android ios swift kotlin kotlin-multiplatform