NotificationCenter

extension NotificationCenter
  • Returns an async sequence that emits when the notification center broadcasts notifications.

    let sequence = NotificationCenter.default.sequence(for: UIDevice.orientationDidChangeNotification)
    
    for await element in sequence {
        print(element)
    }
    
    

    Declaration

    Swift

    public func sequence(
        for name: Notification.Name,
        object: AnyObject? = nil
    ) -> NotificationCenterAsyncSequence