<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/DistributedNotificationCenter/postNotificationName(_:object:userInfo:deliverImmediately:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDistributedNotificationCenter(im)postNotificationName:object:userInfo:deliverImmediately:"
  },
  "title" : "postNotificationName(_:object:userInfo:deliverImmediately:)"
}
-->

# postNotificationName(_:object:userInfo:deliverImmediately:)

Creates a notification with information and an immediate-delivery specifier, and posts it to the receiver.

```
func postNotificationName(_ name: NSNotification.Name, object: String?, userInfo: [AnyHashable : Any]? = nil, deliverImmediately: Bool)
```

## Parameters

`name`

Name of the notification to post. Must not be `nil`.

`object`

Sender of the notification. May be `nil`.

`userInfo`

Dictionary containing additional information. May be `nil`.
  
  > Important:
  > Sandboxed apps can send notifications only if they do not contain a dictionary. If the sending application is in an App Sandbox, `userInfo` *must* be `nil`.

`deliverImmediately`

Specifies when to deliver the notification. When <doc://com.apple.documentation/documentation/Swift/false>, the receiver delivers notifications to their observers according to the suspended-notification behavior specified in the corresponding dispatch table entry. When <doc://com.apple.documentation/documentation/Swift/true>, the receiver delivers the notification immediately to its observers.

## Discussion

This is the preferred method for posting notifications.

The `notificationInfo` dictionary is serialized as a property list, so it can be passed to another task. In the receiving task, it is deserialized back into a dictionary. This serialization imposes some restrictions on the objects that can be placed in the `notificationInfo` dictionary. See XML Property Lists for details.

## See Also

[`+  unarchiveObjectWithData:`](/documentation/Foundation/NSUnarchiver/unarchiveObject(with:))

Decodes and returns the object archived in a given `NSData` object.

[`-  encodeRootObject:`](/documentation/Foundation/NSArchiver/encodeRootObject(_:))

Archives a given object along with all the objects to which it is connected.



---

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)