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.
NSArchiver's companion class,
NSUnarchiver, decodes the data in an archive and creates a graph of objects equivalent to the original set.
- macOS 10.0+
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.