Contents

encodeRootObject(_:)

Archives a given object along with all the objects to which it is connected.

Declaration

func encodeRootObject(_ rootObject: Any)

Parameters

  • rootObject:

    The root object of the object graph to archive.

Discussion

If any object is encountered more than once while traversing the graph, it is encoded only once, but the multiple references to it are stored. (See Archives and Serializations Programming Guide for more information.)

This message must not be sent more than once to a given NSArchiver object; an NSInvalidArgumentException is raised if a root object has already been encoded. If you need to encode multiple object graphs, therefore, don’t attempt to reuse an NSArchiver instance; instead, create a new one for each graph.

See Also

Archiving data