Contents

NotificationCenter.MessageIdentifier

An optional identifier to associate a given message with a given type.

Declaration

protocol MessageIdentifier

Overview

Implement a MessageIdentifier to provide a typed, ergonomic experience at the call point, as described in SE-0299.

For example, given ExampleMessage with a Subject called ExampleSubject:

extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<ExampleMessage> {
    static var eventDidOccur: Self { .init() }
}

This simplifies the call point for clients, as seen here:

let token = center.addObserver(of: exampleSubject, for: .eventDidOccur) { ... }

Topics

Declaring the message type

Identifying cookie storage messages

Identifying undo manager messages

Identifying defaults messages

Identifying metadata query messages

Identifying calendar, date, and time zone messages

Identifying locale messages

Identifying bundle messages

Identifying process info messages

Identifying file handle messages

Identifying port messages

Identifying file manager messages

Identifying bundle resource request messages

Identifying extension messages

Identifying UIKit accessibility messages

Identifying UIKit app life cycle messages

Identifying UIKit content size messages

Identifying UIKIt device messages

Identifying UIKit document messages

Identifying UIKit pasteboard messages

Identifying UIKit responder messages

Identifying UIKit screen messages

Identifying UIKit table messages

Identifying UIKit text field messages

Identifying UIKit text input mode messages

Identifying UIKit text view messages

Identifying UIKit view controller messages

Identifying UIKit focus messages

Identifying UIKit pointer lock state messages

Identifying UIKit scene messages

Identifying AppKit workspace messages

Identifying EventKit messages

Identifying iTunes library messages

Type Properties

See Also

Using message identifiers