---
title: "postNotificationName(_:object:userInfo:deliverImmediately:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/distributednotificationcenter/postnotificationname(_:object:userinfo:deliverimmediately:)"
---

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

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

## Declaration

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

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

### Related Documentation

- [unarchiveObject(with:)](foundation/nsunarchiver/unarchiveobject(with:).md)
- [encodeRootObject(_:)](foundation/nsarchiver/encoderootobject(_:).md)

### Posting Notifications

- [post(name:object:)](foundation/distributednotificationcenter/post(name:object:).md)
- [post(name:object:userInfo:)](foundation/distributednotificationcenter/post(name:object:userinfo:).md)
- [postNotificationName(_:object:userInfo:options:)](foundation/distributednotificationcenter/postnotificationname(_:object:userinfo:options:).md)
