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
name
The name of the notification.
sender
The object sending the notification. The default is
nil
.Return Value
A new
Notification
instance. -
Posts the notification with the given value to the specified center.
Declaration
Swift
public func post(value: Value, center: NSNotificationCenter = .defaultCenter())
Parameters
value
The data to be sent with the notification.
center
The 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
Notification
instance.Declaration
Swift
public func withSender(sender: Sender?) -> Notification
Parameters
sender
The instance posting this notification.
Return Value
A new
Notification
instance.