andreasmattsson
07/25/2019, 1:37 PMclass KotlinWeakViewController(private val weak: WeakReference<UIViewController>) {
constructor(viewController: UIViewController) : this(WeakReference(viewController))
val viewController get() = weak.get()
}
And I have this in my Swift VC:```
private var weakVc: KotlinWeakViewController?
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
//weakVc = KotlinWeakViewController(viewController: self)
weakVc = KotlinWeakViewController(weak: KotlinWeakReference(referred: self))
weakVc = nil
}
deinit {
print("ViewController deinit")
}
```
Unfortunately the ViewController never seems to deinit if I instantiate the KotlinWeakViewController
, regardless of whether I create the WeakReference
on the Kotlin side or on the Swift side, and regardless of whether I keep the reference to the KotlinWeakViewController
around in an instance variable or nil it immediately.kpgalligan
07/25/2019, 4:18 PMandreasmattsson
07/25/2019, 5:28 PMkpgalligan
07/25/2019, 5:35 PMandreasmattsson
07/26/2019, 7:08 AMandreasmattsson
07/26/2019, 8:09 AMkpgalligan
07/26/2019, 1:09 PM