<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NotificationCenter/removeObserver(_:)-2yciv",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSNotificationCenter(im)removeObserver:"
  },
  "title" : "removeObserver(_:)"
}
-->

# removeObserver(_:)

Removes all entries specifying an observer from the notification center’s dispatch table.

```
func removeObserver(_ observer: Any)
```

## Parameters

`observer`

The observer to remove from the dispatch table. Specify an observer to remove only entries for this observer.

## Discussion

Removing the observer stops it from receiving notifications.

If you used [`addObserver(forName:object:queue:using:)`](/documentation/Foundation/NotificationCenter/addObserver(forName:object:queue:using:)) to create your observer, you should call this method or [`removeObserver(_:name:object:)`](/documentation/Foundation/NotificationCenter/removeObserver(_:name:object:)) before the system deallocates any object that [`addObserver(forName:object:queue:using:)`](/documentation/Foundation/NotificationCenter/addObserver(forName:object:queue:using:)) specifies.

If your app targets iOS 9.0 and later or macOS 10.11 and later, and you used [`addObserver(_:selector:name:object:)`](/documentation/Foundation/NotificationCenter/addObserver(_:selector:name:object:)), 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 [`removeObserver(_:name:object:)`](/documentation/Foundation/NotificationCenter/removeObserver(_:name:object:)) with the name and object.

> Important:
> You shouldn’t use this method to remove all observers from a long-lived object because your code may not be the only code adding observers that involve the object.

The following example illustrates how to unregister `someObserver` for all previously registered notifications. This is safe to do in the <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/dealloc> method, but you shouldn’t use it otherwise (use [`removeObserver(_:name:object:)`](/documentation/Foundation/NotificationCenter/removeObserver(_:name:object:)) instead).

```objc
[[NSNotificationCenter defaultCenter] removeObserver:someObserver];
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)