Implementation of
NSCoder
capable of creating sequential archives which
must be read in the same order they were written.
This class implements methods for saving to and
restoring from a serial archive (usually a file
on disk, but can be an
NSData
object) as well as methods that can be used by
objects that need to write/restore themselves.
Note, the sibling class
NSKeyedArchiver
supports a form of archive that is more robust to class changes, and is recommended over this one.
Returns substitute class used to encode objects of
given class. This would have been set through an
earlier call to [NSArchiver
-encodeClassName:intoClassName:].
Specify substitute class used in archiving objects
of given class. This class is written to the archive as
the class to use for restoring the object, instead of
what is returned from [NSObject -classForArchiver].
This can be used to provide backward compatibility
across class name changes. The object is still
encoded by calling encodeWithCoder: as
normal.
The
-resetUnarchiverWithData:atIndex:
method lets you re-use the archive to decode a new
data object or, in conjunction with the 'cursor'
method (which reports the current decoding position
in the archive), decode a second archive that exists in
the data object after the first one.
Subclassing with different input format.
NSUnarchiver normally reads
directly from an
NSData
object using the methods -
to decode type tags for data items, the tag is the
first byte of the character encoding string for
the data type (as provided by '@encode(xxx)'),
possibly with the top bit set to indicate that
what follows is a crossreference to an item
already encoded. Also decode a
crossreference number either to identify
the following item, or to refer to a previously
encoded item. Objects, Classes, Selectors,
CStrings and Pointer items have crossreference
encoding, other types do not.
NSUnarchiver normally uses other
NSData
methods to read the archive header information
from within the method:
[-deserializeHeaderAt:version:classes:objects:pointers:]
to read a fixed size header including archiver version (obtained by [self systemVersion]) and crossreference table sizes.
To subclass NSUnarchiver, you must
implement your own versions of the four
methods above, and override the
'directDataAccess' method to return
NO so that the archiver knows to
use your serialization methods rather than those in
the
NSData
object.
Sets class name unarchivers will use to instantiate
encoded objects when they report their class name
as nameInArchive. This can be used to support
backwards compatibility across class name
changes.
Set class name this unarchiver uses to instantiate
encoded objects when they report their class name
as nameInArchive. This can be used to provide
backward compatibility across class name changes.