Removing Observers
suggest changeSwift 3
//Remove observer for single notification
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: "TestNotification"), object: nil)
//Remove observer for all notifications
NotificationCenter.default.removeObserver(self)
Objective-C
//Remove observer for single notification
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"TestNotification" object:nil];
//Remove observer for all notifications
[[NSNotificationCenter defaultCenter] removeObserver:self];
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents