Instance Property

userInfo

The user information dictionary associated with the notification.

Declaration

@property(readonly, copy) NSDictionary *userInfo;

Discussion

May be nil.

The user information dictionary stores any additional objects that objects receiving the notification might use.

For example, in AppKit, NSControl objects post the NSControlTextDidChangeNotification 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:

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

name

The name of the notification.

object

The object associated with the notification.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software