Instance Method


Encodes state-related information for the object.


optional func encodeRestorableState(with coder: NSCoder)



The coder object to use to encode the state of the object.


You can implement this method for any object that has state information you want to preserve. When deciding what data to save, write the smallest amount of data needed to restore the object to its current configuration. The information you save should be data that you could not easily recreate. You can also save references to other objects, such as the view controller that was using the object.

It is strongly recommended that you call super at some point during your implementation to give parent classes an opportunity to save information too.

See Also

Encoding and Decoding the Object

func decodeRestorableState(with: NSCoder)

Decodes and restores state-related information for the object.

func applicationFinishedRestoringState()

Called after all objects have had a chance to decode their state.