<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/removeObserver(_:forKeyPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime",
      "ObjectiveC"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)removeObserver:forKeyPath:"
  },
  "title" : "removeObserver(_:forKeyPath:)"
}
-->

# removeObserver(_:forKeyPath:)

Stops the observer object from receiving change notifications for the property specified by the key path relative to the object receiving this message.

```
func removeObserver(_ observer: NSObject, forKeyPath keyPath: String)
```

## Parameters

`observer`

The object to remove as an observer.

`keyPath`

A key-path, relative to the object receiving this message, for which `observer` is registered to receive KVO change notifications.

## Discussion

It is an error to call [`removeObserver(_:forKeyPath:)`](/documentation/ObjectiveC/NSObject-swift.class/removeObserver(_:forKeyPath:)) for an `object` that has not previously been registered as an observer.

Be sure to invoke this method (or [`removeObserver(_:forKeyPath:context:)`](/documentation/ObjectiveC/NSObject-swift.class/removeObserver(_:forKeyPath:context:))) before any object specified in [`addObserver(_:forKeyPath:options:context:)`](/documentation/ObjectiveC/NSObject-swift.class/addObserver(_:forKeyPath:options:context:)) is deallocated.

---

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)