Reputation: 139
Are there reserved keywords for destructors in Swift? Is there even a need for such a thing in this language?
Upvotes: 13
Views: 9866
Reputation: 42598
Are there reserved keywords for destructors in Swift?
deinit
(Deinitialization) handles cleanup which should occur before the object is released.
Is there even a need for such a thing in this language?
There are a few standard things done in deinit
. Remove observers, synchronize the state of an object, and write trace messages for debugging. Other things are possible, just avoid long running chunks of code.
Upvotes: 25