NSArchiver — Mac OS X 10.0
This class is a concrete subclass of
to archive a network of interconnected objects (an
into a data format that can be written to disk. The archive operation
NSMutableData object containing this
data. To archive an object, the class method
archivedDataWithRootObject: is used, which returns
NSData object containing the archived object.
Alternatively, we can archive directly to a file using the class
archiveRootObject:toFile:. It is also
possible to initialize an instance of
with a pointer to an instance of
providing a more persistent archiving engine than if we simply used
the class methods.
retrieve objects from an
archive, we use another subclass of
NSUnarchiver support an archival scheme where
objects and variables must be unarchived in the same order that they
were archived. Mac OS X 10.2 introduced keyed-archiving, whereby
every object and variable in an archive has an associated key that
frees us from having to be strictly bound to the original archive
format. This has great benefits for improving the compatability of
data files between versions of an application.
For instances of a class to be archivable, that class must conform to
NSCoding protocol. See the
NSCoding protocol description and Chapter 2 for more information about archiving.
@interface NSArchiver : NSCoder