Type Method


Archives an object graph rooted at a given object to a file at a given path.


class func archiveRootObject(_ rootObject: Any, toFile path: String) -> Bool



The root of the object graph to archive.


The path of the file in which to write the archive.

Return Value

true if the operation was successful, otherwise false.


This method archives the graph formed by the root object to a data object, then atomically writes it to the given path. The format of the archive is PropertyListSerialization.PropertyListFormat.binary.

See Also

Archiving Data

class func archivedData(withRootObject: Any, requiringSecureCoding: Bool) -> Data

Encodes an object graph with the given root object into a data representation, optionally requiring secure coding.

func finishEncoding()

Instructs the receiver to construct the final data stream.

var encodedData: Data

The encoded data for the archiver.

var outputFormat: PropertyListSerialization.PropertyListFormat

The format in which the receiver encodes its data.

var requiresSecureCoding: Bool

Indicates whether the archiver requires all archived classes to resist object substitution attacks.

class func archivedData(withRootObject: Any) -> Data

Returns a data object that contains the encoded form of the object graph formed by the given root object.