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

# removeObserver(_:forKeyPath:context:)

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

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

## Parameters

`observer`

The object to remove as an observer.

`keyPath`

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

`context`

Arbitrary data that more specifically identifies the observer to be removed.

## Discussion

Examining the value in `context` you are able to determine precisely which [`addObserver(_:forKeyPath:options:context:)`](/documentation/ObjectiveC/NSObject-swift.class/addObserver(_:forKeyPath:options:context:)) invocation was used to create the observation relationship. When the same observer is registered for the same key-path multiple times, but with different context pointers, an application can determine specifically which object to stop observing. It is an error to call [`removeObserver(_:forKeyPath:context:)`](/documentation/ObjectiveC/NSObject-swift.class/removeObserver(_:forKeyPath:context:)) if the object has not been registered as an observer.

Be sure to invoke this method (or [`removeObserver(_:forKeyPath:)`](/documentation/ObjectiveC/NSObject-swift.class/removeObserver(_:forKeyPath:))) 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)