It really depends on the role of the class in which you subscribe to NSNotificationCenter notifications. If you subscribed to:
Uiview
Then you must unsubscribe as soon as the view becomes invisible to the user. To save processor cycles and not consume resources until the user sees the view.
UIViewController
It also depends on the action you are about to take in response to the notification. If this is just a user interface setup, you should unsubscribe as soon as the view controller disappears from the screen.
Your application service level
It is okay to have a .removeObserver inside deinit (). however, even here I am inclined to offer you more details about when you sign up and unsubscribe from NSNotificationCenter notifications and put them in the methods of starting and stopping your service.
Keenle
source share