Arkadii Ivanov
03/01/2020, 11:02 PMfun myViewController(): UIViewController = MyViewControllerImpl()
private class MyViewControllerImpl : UIViewController(nibName = null, bundle = null) {
private val button = UIButton()
override fun viewDidLoad() {
super.viewDidLoad()
button.addTarget(target = this, action = sel_registerName("onClick"), forControlEvents = UIControlEventTouchUpInside)
view.addSubview(button)
}
@ObjCAction
private fun onClick() {
}
}
Sam
03/01/2020, 11:18 PMArkadii Ivanov
03/01/2020, 11:21 PMaddTarget
would retain the reference. In this case would it be a memory leak?Sam
03/01/2020, 11:26 PMArkadii Ivanov
03/01/2020, 11:29 PMdeinit
and weak var
. In Kotlin we don't have any. How to deal with cyclic references in such cases (when the class is created and used from Swift)?Sam
03/02/2020, 3:22 AMArkadii Ivanov
03/02/2020, 9:22 AM