https://kotlinlang.org logo
#ios
Title
# ios
s

Stephen

03/18/2023, 9:13 PM
Hi, I wonder if anyone can help me please. I've only just started using SwiftUI and I'm trying to return a value, either an object or just a boolean from my suspend signIn method from shared in multiplatform mobile. I've tried a few different was like....... @State var isSuccessful = false let result = try! await auth.signIn(username, password) isSuccessful = result ...... but this tells me Cannot assign value of type 'KotlinBoolean' to type 'Bool'
I put Task{ await signIn() } around the call and added async to the method and put my call to the shared method in a do{} catch{} with a try await on the call and then added kotlin.native.binary.objcExportSuspendFunctionLaunchThreadRestriction=none to the gradle.properties. This seems to be working. Not sure if its the best approach though.
k

Kevin S

03/22/2023, 2:15 PM
I believe
KotlinBoolean
has a variable
boolValue
or something similar, that you can map the result to. You can also use a
Flow
in kotlin and then listen to that on the
swift
side, though that is more likely for a stream of information. You can use the KMP Native Coroutines Library for that
3 Views