UIObjectRestoration Protocol Reference

Framework
/System/Library/Framework/UIKit.framework
Availability
Available in iOS 7.0 and later.
Declared in
UIStateRestoration.h

Overview

The UIObjectRestoration protocol should be adopted by classes that act as "restoration classes” for objects during the state restoration process. The method in this protocol should be used to return the object if it already exists or create it if needed.

A restorable object must set its objectRestorationClass property to the class that adopts this protocol.

Tasks

Creating the Restorable Object

Class Methods

objectWithRestorationIdentifierPath:coder:

Asks the receiver to provide the object that corresponds to the specified identifier information. (required)

+ (id<UIStateRestoring>) objectWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder
Parameters
identifierComponents

An array of NSString objects corresponding to the restoration identifiers of the desired object and all of its ancestors in the restoration hierarchy. The last value in the array is the restoration identifier of the desired object. Earlier entries represent the restoration identifiers of its ancestors.

coder

The keyed archiver containing the app’s saved state information.

Return Value

The object to use or nil if you do not want to restore this object now.

Discussion

Your implementation of this method should create (or find) the corresponding object and return it. If your restoration class determines that the object should not be restored, it may return nil from this method.

You use the strings in the identifierComponents parameter to identify the object being requested. The object may be at the end of a restoration hierarchy containing your app’s view controllers and other objects. The strings in the identifierComponents array identify the path through this hierarchy to the desired object.

It is not always necessary to create a new object in your implementation of this method. You can also return an existing object that was created by another means. For example, if the object had already been created by your app delegate at initialization time, you would return that object rather than create a new one.

Your implementation of this method may use any data in the provided coder to assist in the restoration process. However, you do not need to restore the entire state of the object at this point. During a later pass, objects that define a decodeRestorableStateWithCoder: method are given a chance to restore their state from the same coder object.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIStateRestoration.h