kmm.icerock.dev icon indicating copy to clipboard operation
kmm.icerock.dev copied to clipboard

Отразить как получать NSError от ios кода в kotlin

Open Alex009 opened this issue 4 years ago • 0 comments

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!!)
        }

Alex009 avatar Jun 22 '21 06:06 Alex009