Removes all entries specifying an observer from the notification center's dispatch table.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The observer to remove from the dispatch table. Specify an observer to remove only entries for this observer.
Removing the observer stops it from receiving notifications.
If you used
add to create your observer, you should call this method or
remove before the system deallocates any object that
If your app targets iOS 9.0 and later or macOS 10.11 and later, and you used
add, you do not need to unregister the observer. If you forget or are unable to remove the observer, the system cleans up the next time it would have posted to it.
When removing an observer, remove it with the most specific detail possible. For example, if you used a name and object to register the observer, use
remove with the name and object.
The following example illustrates how to unregister
some for all previously registered notifications. This is safe to do in the
dealloc method, but you shouldn’t use it otherwise (use