---
title: "CFNotificationCenterAddObserver(_:_:_:_:_:_:)"
framework: Core Foundation
role: symbol
role_heading: Function
path: "corefoundation/cfnotificationcenteraddobserver(_:_:_:_:_:_:)"
---

# CFNotificationCenterAddObserver(_:_:_:_:_:_:)

Registers an observer to receive notifications.

## Declaration

```swift
func CFNotificationCenterAddObserver(_ center: CFNotificationCenter!, _ observer: UnsafeRawPointer!, _ callBack: CFNotificationCallback!, _ name: CFString!, _ object: UnsafeRawPointer!, _ suspensionBehavior: CFNotificationSuspensionBehavior)
```

## Parameters

- `center`: The notification center to which to add the observer.
- `observer`: The observer. In macOS 10.3 and later, this parameter may be NULL.
- `callBack`: The callback function to call when object posts the notification named name.
- `name`: The name of the notification to observe. If NULL, callback is called for any notification posted by object. If center is a Darwin notification center, this value must not be NULL.
- `object`: The object to observe. For distributed notifications, object must be a CFString object. If NULL, callback is called when a notification named name is posted by any object. If center is a Darwin notification center, this value is ignored.
- `suspensionBehavior`: Flag indicating how notifications should be handled when the application is in the background. See doc://com.apple.corefoundation/documentation/CoreFoundation/CFNotificationSuspensionBehavior for the list of available values. If center is a Darwin notification center, this value is ignored.

## Discussion

Discussion Notification delivery is registered for the main thread. If you need to control which thread processes a notification, your callback function must be able to forward the notification to the proper thread. You can use a CFMessagePort object or a custom CFRunLoopSource object to send notifications to the correct thread’s run loop.

## See Also

### Related Documentation

- [CFRunLoopSource](corefoundation/cfrunloopsource.md)
- [CFMessagePort](corefoundation/cfmessageport.md)

### Adding and Removing Observers

- [CFNotificationCenterRemoveEveryObserver(_:_:)](corefoundation/cfnotificationcenterremoveeveryobserver(_:_:).md)
- [CFNotificationCenterRemoveObserver(_:_:_:_:)](corefoundation/cfnotificationcenterremoveobserver(_:_:_:_:).md)
