Tutorial by Examples: deinit

There are times with multiple static objects where you need to be able to guarantee that the singleton will not be destroyed until all the static objects that use the singleton no longer need it. In this case std::shared_ptr can be used to keep the singleton alive for all users even when the static...
class ClassA { var timer: NSTimer! init() { // initialize timer } deinit { // code timer.invalidate() } }

Page 1 of 1