When you exit the current view using dismissviewcontrolleranimated , The View object is theoretically cleared ,
which means it goes in. Destructors for the current class Deinit inside. But sometimes it turns out that the dismiss didn't go into the destruction, and there were often strange phenomena
Sometimes there's no problem, and it doesn't mean that we can ignore it.
The reason for not entering a destructor is because the current object contains a delegate that has not been disposed to exist. For example, when I opened this view, it was associated with this delegate event.
In this case, you will not be able to enter the destructor after dismiss, so you need to manually release all the delegates before dismiss, specifically to the above example, that is, in the execution dismissviewcontrolleranimated You must add a line of code before
This allows you to release all resources at the time of exiting, to avoid the release of dirty, memory overflow and other situations.
This should be a bug in swift, which should theoretically release all resources automatically when exiting the view, and should not allow the programmer to do it manually.
Notable points about dismissviewcontrolleranimated (Deinit)