---
title: "removeObserver(_:forKeyPath:)"
framework: objectivec
role: symbol
role_heading: Instance Method
path: "objectivec/nsobject-swift.class/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.

## Declaration

```swift
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

Discussion It is an error to call removeObserver(_:forKeyPath:) for an object that has not previously been registered as an observer. Be sure to invoke this method (or removeObserver(_:forKeyPath:context:)) before any object specified in addObserver(_:forKeyPath:options:context:) is deallocated.

## See Also

### Registering for Observation

- [addObserver(_:forKeyPath:options:context:)](objectivec/nsobject-swift.class/addobserver(_:forkeypath:options:context:).md)
- [removeObserver(_:forKeyPath:context:)](objectivec/nsobject-swift.class/removeobserver(_:forkeypath:context:).md)
