<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFNotificationCenterAddObserver(_:_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFNotificationCenterAddObserver"
  },
  "title" : "CFNotificationCenterAddObserver(_:_:_:_:_:_:)"
}
-->

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

Registers an observer to receive notifications.

```
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 [`CFNotificationSuspensionBehavior`](/documentation/CoreFoundation/CFNotificationSuspensionBehavior) for the list of available values.

    If     `center`     is a Darwin notification center, this value is ignored.

## 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

[`CFRunLoopSource`](/documentation/CoreFoundation/CFRunLoopSource)

[`CFMessagePort`](/documentation/CoreFoundation/CFMessagePort)



---

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)