(or a collection of interconnected objects, known as a graph) into a
NSData representation is often useful or
necessary. Objects that are archived into an
NSData object can be transported over network
connections or interprocess communication channels and saved to the
filesystem. Later, the original graph of objects can be reconstituted
from the archive data.
Foundation provides five classes to support the creation and
extraction of archives, all subclasses of
declares the common interface for
encoding and decoding objects and other Objective-C data types. For
encodeObject method encodes an object
into an archive, and methods such as
encodeRect: support encoding C data types such
as integers and common Cocoa data structures.
NSCoder does not implement these methods; it is an
abstract class. Rather, subclasses implement the appropriate methods
for their particular purpose.
provide a straightforward way of encoding
and decoding objects and scalars, but they have limitations. The
biggest limitation is that objects in an archive can be decoded only
in the same order in which they were encoded. Because of this
constraint, changing an encoding system is difficult once it has been
classes solve this problem by associating ...