Notable points about dismissviewcontrolleranimated (Deinit)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.