Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSDistributedNotificationCenterMBS class.

NSDistributedNotificationCenterMBS.addObserver(observer as NSNotificationObserverMBS, name as string, theObject as Variant, suspensionBehavior as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Notifications MBS MacBase Plugin 9.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds an entry to the receiver's dispatch table with a specific observer and suspended-notifications behavior, and optional notification name and sender.

observer: Object registering as an observer. Must not be nil.
name: The name of the notification for which to register the observer; that is, only notifications with this name are delivered to the observer. When nil, the notification center doesn't use a notification's name to decide whether to deliver it to the observer.
theObject: The object whose notifications the observer wants to receive; that is, only notifications sent by this sender are delivered to the observer. When nil, the notification center doesn't use a notification's sender to decide whether to deliver it to the observer.
suspensionBehavior: Notification posting behavior when notification delivery is suspended.

The receiver does not retain notificationObserver. Therefore, you should always send removeObserver to the receiver before releasing notificationObserver.

NSDistributedNotificationCenterMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Notifications MBS MacBase Plugin 9.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a new instance with the default distributed notification center, representing the local notification center for the computer.

Default distributed notification center for the computer.

This method calls notificationCenterForType: with an argument of NSLocalNotificationCenterType.

NSDistributedNotificationCenterMBS.postNotificationName(name as string, theObject as string, userInfo as dictionary, deliverImmediately as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Notifications MBS MacBase Plugin 9.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a notification with information and an immediate-delivery specifier, and posts it to the receiver.

name: Name of the notification to post. Must not be nil.
theObject: Sender of the notification. May be "".
userInfo: Dictionary containing additional information. May be nil.
deliverImmediately: Specifies when to deliver the notification. When false, the receiver delivers notifications to their observers according to the suspended-notification behavior specified in the corresponding dispatch table entry. When true, the receiver delivers the notification immediately to its observers.

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:

NSDistributedNotificationCenterMBS.postNotificationName(name as string, theObject as string, userInfo as dictionary, options as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Notifications MBS MacBase Plugin 9.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a notification with information, and posts it to the receiver.
Example
dim notifyData as string = "Hello World"
dim notifyName as string = "Test"

Dim notifyDict As New Dictionary
notifyDict.Value("nData")=notifyData
NSDistributedNotificationCenterMBS.DefaultCenter.postNotificationName(notifyName, "", notifyDict, 2)

name: Name of the notification to post. Must not be nil.
theObject: Sender of the notification. May be "".
userInfo: Dictionary containing additional information. May be nil.
options: Specifies how the notification is posted to the task and when to deliver it to its observers.

The userInfo 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:

NSDistributedNotificationCenterMBS.suspended as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Notifications MBS MacBase Plugin 9.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
A boolean value that indicates whether notification delivery is suspended.

The NSApplication class automatically suspends distributed notification delivery when the application is not active. Applications based on the Application Kit framework should let AppKit manage the suspension of notification delivery. Foundation-only programs may have occasional need to use this method.
(Read and Write computed property)

The items on this page are in the following plugins: MBS MacBase Plugin.


The biggest plugin in space...