Instance Property


An object encapsulating a user activity supported by this responder.


var userActivity: NSUserActivity? { get set }


By setting the userActivity property on a responder, the NSUserActivity object becomes managed by AppKit. You should override updateUserActivityState(_:) to write lazily any state data representing the user’s activity to the userInfo dictionary. User activities managed by AppKit are saved automatically at appropriate times. Multiple responders can share a single NSUserActivity instance, in which case they all get a callback, such as updateUserActivityState(_:), when the system updates the user activity object.

In macOS, NSUserActivity objects managed by NSResponder automatically becomeCurrent() based on the main window and the responder chain.

A responder object can set its userActivity property to nil if it no longer wants to participate. Any NSUserActivity objects that are managed by AppKit but which have no associated responders (or documents) are automatically invalidated.

This property can be used from any thread. It is KVO observable.

See Also

Supporting User Activities

func updateUserActivityState(NSUserActivity)

Updates the state of the given user activity.