Are there such things as destructors in Swift?

Are there any reserved keywords for destructors in Swift? Is there a need for such a thing in this language?

+6
source share
1 answer

Are there any reserved keywords for destructors in Swift?

deinit (Deinitialization) handles the cleanup that must occur before an object is released.

Is there a need for such a thing in this language?

There are several standard things in deinit . Remove observers, synchronize the state of the object and write trace messages for debugging. Other things are possible, just avoid long snippets of code.

+14
source

All Articles