Contents

registerObject(forStateRestoration:restorationIdentifier:)

Registers a custom object for use with the state restoration system.

Declaration

class func registerObject(forStateRestoration object: any UIStateRestoring, restorationIdentifier: String)

Parameters

  • object:

    The object to be registered with the restoration archive. The object must adopt the Uistaterestoring protocol. This parameter must not be nil.

  • restorationIdentifier:

    The restoration identifier for the object. UIKit uses this parameter to distinguish the object from other objects in the archive. This parameter must not be nil.

Mentioned in

Discussion

You use this method to register objects that you want to save as part of the overall state restoration process. Registering the object makes it available for inclusion in the restoration archive but does not automatically include it. To include the object, refer to it from one of your other interface objects. For example, you might write out a reference to the object from the encodeRestorableState(with:) method of one of your view controllers.

See Also

Managing state restoration