Thursday, January 18, 2018

What is a deinitializer in Swift?

If you need to perform additional cleanup of your custom classes, it's possible to define a block called deinit. The syntax is the following:

deinit { //Your statements for cleanup here }

Typically, this type of block is used when you have opened files or external connections and want to close them before your class is deallocated.