kmm.icerock.dev
kmm.icerock.dev copied to clipboard
Отразить как получать NSError от ios кода в kotlin
private fun createLocalWallet(
name: String,
createSwiftWallet: (CPointer<ObjCObjectVar<NSError?>>) -> SwiftWallet
): LocalWallet {
val (result, error) = memScoped {
val p = alloc<ObjCObjectVar<NSError?>>()
val result: SwiftWallet? = runCatching {
createSwiftWallet(p.ptr)
}.getOrNull()
result to p.value
}
if (error != null) throw error.toException()
else return LocalWallet(name, result!!)
}