Contents

NSArchiver

A coder that stores an object’s data to an archive.

Declaration

class NSArchiver

Overview

NSArchiver, a concrete subclass of NSCoder, provides a way to encode objects into an architecture-independent format that can be stored in a file. When you archive a graph of objects, the class information and instance variables for each object are written to the archive. The companion class NSUnarchiver decodes the data in an archive and creates a graph of objects equivalent to the original set.

NSArchiver stores the archive data in a mutable data object (NSMutableData). After encoding the objects, you can have the NSArchiver object write this mutable data object immediately to a file, or you can retrieve the mutable data object for some other use.

In macOS 10.2 and later, NSArchiver and NSUnarchiver have been replaced by NSKeyedArchiver and NSKeyedUnarchiver respectively—see Archives and Serializations Programming Guide.

Topics

Initializing an NSArchiver

Archiving data

Getting the archived data

Substituting classes or objects

Constants

Initializers

See Also

Deprecated