Hello guys... is it possible to make a reference o...
# kotlin-native
m
Hello guys... is it possible to make a reference of a native Kotlin Class to an
COpaquePointer
? in Swift we can do something like:
Copy code
var context = SCNetworkReachabilityContext(version: 0, info: nil, retain: nil, release: nil, copyDescription: nil)
<http://context.info|context.info> = Unmanaged<Reachability>.passUnretained(self).toOpaque()
where
self
is a the Swift class that contain this code...
a
Hi, are you talking about something like that?
🎉 1
👍 1
m
just to me understand:
StableRef.create(myKClassInstance)
is the same of a
Unmanaged<MyKClass>.passUnretained(this)
? I mean, this has the same effect...
a
I’m not so familiar with Swift, but I suppose they are similar. From what I see in the documentation - both of them “prepare” a reference to be represented as a pointer.
m
nice, thank you so much 👍
s
Note that you
StableRef
should eventually be disposed manually (using
.dispose
)
m
yeah, I'm aware, thank you 🙂