class NotificationCenter.Notifications
An asynchronous sequence of notifications generated by a notification center.
Availability 有効性
Technology
func notifications(named name: Notification
.Name
, object: AnyObject
? = nil) -> NotificationCenter
.Notifications
name
A notfiication name. The sequence includes only notifications with this name.
object
A source object of notifications. Specify a sender object to deliver only notifications from that sender. When nil
, the notification center doesn’t consider the sender as a criteria for delivery.
An asynchronous sequence of notifications from the center.
Use this method to receive notifications from the center as an Async
. You iterate over this sequence with for
-await
-in
syntax.
The following iOS example iterates over an asynchronous sequence of orientation
notifications. It uses the Async
method filter(_:)
to only receive notifications when the device rotates into the upright portrait orientation.
class NotificationCenter.Notifications