Protocols
The following protocols are available globally.
-
A notification that can be posted by a
TypedNotificationCenterinstance.TypedNotificationprovides a type-safe alternative to Foundation’sNotificationtype. All conforming types must specify the type of theobjectattached to the notification. Conforming types can attach additional data to the notification as properties. This replaces stringly typeduserInfodictionary attached to FoundationNotificationsConforming to
TypedNotificationConforming types must declare the type of the object attached to the notification and provide storage for it. For example, a notification posted by a
DataStoreobject might look like this:struct DataStoreDidSaveNotification: TypedNotification { /// The data store posting the notification. let object: DataStore }Customising the Notification Name
A default notification name for conforming types is generated in a protocol extension. The name consists of the name of the notification type prefixed by
AJJ. You can specify a different name by implementing the staticnameproperty on your notification types:
See morestruct DataStoreDidSaveNotification: TypedNotification { static let name = Notification.Name("XYZDataStoreDidSave") /// The data store posting the notification. let object: DataStore }Declaration
Swift
public protocol TypedNotification
-
A type that can post
See moreTypedNotifications and add notification observers.Declaration
Swift
public protocol TypedNotificationCenter
View on GitHub
Protocols Reference