Where to remove observer for NSNotification in Swift?
Where should I remove the observer for NSNotification in Swift, since viewDidUnload and dealloc() are unavailable? Use below method which functions same as dealloc . deinit { // Release all resources // perform the deinitialization } A deinitializer is called immediately before a class instance is deallocated. You write deinitializers with the deinit keyword, similar to how intializers are written with the init keyword. Deinitializers are only available on class types. Swift Deinitializer As of iOS 9 (and OS X 10.11), you don't need to remove observers yourself, if you're not using block based