Notification
public struct Notification <Value, Sender: AnyObject>
A typed notification that contains a name and optional sender.
Note
TheValue type parameter acts as a phantom type, restricting the notification to posting only values of this type.
-
The name of the notification.
Declaration
Swift
public let name: String -
The object that posted the notification.
Declaration
Swift
public let sender: Sender?
-
Constructs a new notification instance having the specified name and sender.
Declaration
Swift
public init(name: String, sender: Sender? = nil)Parameters
nameThe name of the notification.
senderThe object sending the notification. The default is
nil.Return Value
A new
Notificationinstance. -
Posts the notification with the given value to the specified center.
Declaration
Swift
public func post(value: Value, center: NSNotificationCenter = .defaultCenter())Parameters
valueThe data to be sent with the notification.
centerThe notification center from which the notification should be dispatched. The default is
NSNotificationCenter.defaultCenter(). -
Returns a new notification with the receiver’s name and the specified sender.
Warning
Note that this function returns a new
Notificationinstance.Declaration
Swift
public func withSender(sender: Sender?) -> NotificationParameters
senderThe instance posting this notification.
Return Value
A new
Notificationinstance.
View on GitHub
Notification Struct Reference