https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
d

Davin reinaldo gozali

03/15/2021, 3:01 AM
Hi all, I want to ask related to Cinterop code that produce function like this :
fun myFunction(param1 : String, error : error : CPointer<ObjCObjectVar<NSError?>>?)
how to user that kind of CPointer type ?
a

Artyom Degtyarev [JB]

03/15/2021, 7:32 AM
Hello, @Davin reinaldo gozali! You have to allocate an object containing
NSError
and send the pointer to the function. IIRC, something like that should work
Copy code
memScoped {   // All objects allocated in this block will be marked as free when its over, I use it for simplicity here.
   val startError = alloc<ObjCObjectVar<NSError?>>()
   myFunction(param1 = "Hello", error = startError.ptr))
}
👍 1
d

Davin reinaldo gozali

03/15/2021, 8:02 AM
okay, that works.. thank you
5 Views