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