Is there a way of specifying a variable to be `wea...
# kotlin-native
c
Is there a way of specifying a variable to be
weak
or
unowned
when running on iOS?
s
c
Can this be used on multiplatform?
s
Yes. You can declare
Copy code
expect class WeakReference<T : Any>(referred: T) {
    fun clear()
    fun get(): T?
}
in common sources,
Copy code
actual typealias WeakReference<T> = java.lang.ref.WeakReference<T>
in Android sources and
Copy code
actual typealias WeakReference<T> = kotlin.native.ref.WeakReference<T>
in iOS sources
c
Interesting, thanks