I would like to use a finalize hook in iOS NSObjec...
# kotlin-native
p
I would like to use a finalize hook in iOS NSObject. How can I implement
dealloc
in Kotlin? I will as a final step call super.dealloc to dispose KRefSharedHolder, but before that I would like to clean-up scoped pointers
o
there's no way to do destructors in Kotlin/Native, although you could try your luck with Objective-C deinitializers
p
I know there’s no way to do it, within K/N, but I can’t see how dealloc is properly rendered into the NSObject via IR. Is that even possible or is the dealloc stripped / overwritten always by the K/N runtime?
s
You can’t override
dealloc
in Kotlin for now. Consider implementing special cleaner class in Objective-C and then importing it to Kotlin.
l
@svyatoslav.scherbina I'm not familiar with Obj-C and interop with it apart from platform libs. Is there such an example for a library module?
s
Please refer to the documentation.