Deinit not called on a UIViewController, but Dealloc is

前端 未结 2 2111
生来不讨喜
生来不讨喜 2020-12-31 02:02

It seems like the Swift equivalent of dealloc is deinit. However, when you attempt to define the method on a UIViewController, it doesn\'t behave as you would expect...

2条回答
  •  忘掉有多难
    2020-12-31 02:56

    I haven't tried it yet but I did find this for you:

    It seems the function won't be called unless some code is put inside the deinit (weird) must be part of swift's optimisation stage.

    Try putting a print statement inside your deinit as suggested and report your findings

提交回复
热议问题