Instance Property インスタンスプロパティ

userInfo

Storage for values or objects related to this notification. この通知に関係する値またはオブジェクトに対するストレージ。

Declaration 宣言

var userInfo: [AnyHashable : Any]?

Discussion 議論

The user information dictionary stores any additional objects that objects receiving the notification might use. ユーザ情報辞書はあらゆる追加オブジェクトを格納します、それは通知を受け取っているオブジェクトが使うかもしれません。

For example, in AppKit, NSControl objects post the textDidChangeNotification whenever the field editor (an NSText object) changes text inside the NSControl. This notification provides the NSControl object as the notification's associated object. In order to provide access to the field editor, the NSControl object posting the notification adds the field editor to the notification's user information dictionary. Objects receiving the notification can access the field editor and the NSControl object posting the notification as follows: 例えば、AppKitにおいて、NSControlオブジェクトはtextDidChangeNotificationを投函します、フィールドエディタ(NSTextオブジェクト)がテキストをNSControl内部で変更する場合はいつでも。この通知は、NSControlオブジェクトを通知の持つ連想オブジェクトとして提供します。フィールドエディタに対するアクセスを提供する手段として、通知を投函しているNSControlオブジェクトは、フィールドエディタを通知の持つユーザ情報辞書へ追加します。通知を受け取っているオブジェクトは、フィールドエディタおよび通知を投函しているNSControlオブジェクトにアクセスできます、次のように:


func controlTextDidChange(_ notification: Notification) 
{
    if let fieldEditor = notification.userInfo?["NSFieldEditor"] as? NSText,
        let postingObject = notification.object as? NSControl
    {
        // work with the field editor and posting object
    }
}

See Also 参照

Getting Notification Information 通知情報を得る