pyryjook
06/08/2019, 6:39 AMextension
part in Kotlin.
lass LocationService: NSObject {
let locationManager: CLLocationManager
init(locationManager: CLLocationManager = CLLocationManager()) {
self.locationManager = locationManager
super.init()
self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
self.locationManager.delegate = self
}
func getCurrentLocation() {
self.locationManager.requestLocation()
self.locationManager.requestWhenInUseAuthorization()
}
}
extension LocationService: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations:[CLLocation]) {
guard let location = locations.first else { return }
print("The location is: \(location)")
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("Error: \(error)")
}
}
I do know that the original CLLocationManagerDelegate
protocol is actually interface with a name CLLocationManagerDelegateProtocol
on the Kotlin/Native side.
I tried googling, but did not find any examples on how to approach Swift extensions in Kotlin/Native. Any help would be highly appreciated, thanks!pyryjook
06/08/2019, 6:45 AMgildor
06/08/2019, 7:03 AMpyryjook
06/08/2019, 7:32 AMgildor
06/08/2019, 8:48 AMsvyatoslav.scherbina
06/10/2019, 7:20 AMCLLocationManagerDelegateProtocol
directly with LocationService
.