Aditya Kurkure
03/07/2022, 3:05 PM(UIBackgroundFetchResult) -> void
from swift to Kotlin?
Currently the method I have written in kotlin expects a (UIKUIBackgroundFetchResult) -> void
when called from swift.Sebastien Leclerc Lavallee
03/08/2022, 3:35 AMfun doSomething(with: String, completion: (Time) -> Void) { }
Aditya Kurkure
03/08/2022, 11:51 AMUIKUIBackgroundFetchResult
instead of UIBackGroundFetchResult though.Sebastien Leclerc Lavallee
03/08/2022, 2:35 PMUIBackgroundFetchResult
but KMM translate it to UIKUIBackgroundFetchResult
🤔 Hum… considering they are basically the same but with different names, I would cast the UIKUI version to UI. But this would need to be done on the Swift side.Aditya Kurkure
03/11/2022, 9:01 AMAdrian Witaszak
02/14/2023, 2:09 PMIOSFileKt.awaitResult { result in
if result.isFailure {
completionHandler(.failed)
} else {
completionHandler(.newData)
}
}
Aditya Kurkure
02/28/2023, 1:58 PMDarron Schall
10/03/2023, 2:14 PMiosMain
:
fun kotlinMethodReturningUIBackgroundFetchResult(): UIBackgroundFetchResult {
// Do some work, then return something like:
return UIBackgroundFetchResult.UIBackgroundFetchResultNewData
}
Here's how I handle this in Swift:
// Even though the kotlin method returns `UIBackgroundFetchResult`
// it gets translated to `UIKUIBackgroundFetchResult`
// when exported to ObjC
let uikUIBackgroundFetchResult = kotlinMethodReturningUIBackgroundFetchResult()
// Convert the `UIKUIBackgroundFetchResult` back to the expected `UIBackgroundFetchResult` type
let rawValue = UInt(uikUIBackgroundFetchResult.value)
let backgroundFetchResult = UIBackgroundFetchResult(rawValue: rawValue)
Not ideal, but keeps the conversation back to UIBackgroundFetchResult
on the Swift side relatively straightforward.