- Inherits from:
- NSCoder : NSObject
- Conforms to:
- NSObject
- (NSObject)
Declared in:
- Foundation/NSArchiver.h
NSUnarchiver, a concrete subclass of NSCoder, defines methods for decoding a set of Objective-C objects from an archive. Such archives are produced by objects of the NSArchiver class. See the NSCoder and NSArchiver specifications for an introduction to archiving.
While unarchiving, NSUnarchiver performs a variety of consistency checks on the incoming data stream. NSUnarchiver raises an NSInconsistentArchiveException when:
For a description of type codes, see the discussion of the @encode() compiler directive in Object-Oriented Programming and the Objective-C Language.
Invoking inappropriate methods can also lead to errors. NSUnarchiver's superclass, NSCoder, provides methods for both encoding and decoding. However, only the decoding methods are applicable to NSUnarchiver; don't send an NSUnarchiver any encode... messages.
- Initializing an NSUnarchiver
- - initForReadingWithData:
- Decoding objects
- + unarchiveObjectWithData:
- + unarchiveObjectWithFile:
- Managing an NSUnarchiver
- - isAtEnd
- - objectZone
- - setObjectZone:
- - systemVersion
- Substituting classes or objects
- + classNameDecodedForArchiveClassName:
- + decodeClassName:asClassName:
- - classNameDecodedForArchiveClassName:
- - decodeClassName:asClassName:
- - replaceObject:withObject:
+ (NSString *)classNameDecodedForArchiveClassName:(NSString
*)nameInArchive
Note that individual instances of NSUnarchiver can each be given their own class name mappings by invoking the instance method decodeClassName:asClassName:. The NSUnarchiver class has no information about these instance-specific mappings, however, so they don't affect the return value of classNameDecodedForArchiveClassName:.
See Also: - classNameDecodedForArchiveClassName:
+ (void)decodeClassName:(NSString
*)nameInArchive
asClassName:(NSString *)trueName
Note that there's also an instance method of the same name. An instance of NSUnarchiver can maintain its own mapping of class names. However, if both the class method and the instance method have been invoked using an identical value for nameInArchive, the class method takes precedence.
See Also: + classNameDecodedForArchiveClassName:, - decodeClassName:asClassName:
+ (id)unarchiveObjectWithData:(NSData
*)data
See Also: - encodeRootObject: (NSArchiver)
+ (id)unarchiveObjectWithFile:(NSString
*)path
- (NSString *)classNameDecodedForArchiveClassName:(NSString
*)nameInArchive
See Also: + classNameDecodedForArchiveClassName:
- (void)decodeClassName:(NSString
*)nameInArchive
asClassName:(NSString *)trueName
Note that there's also a class method of the same name. The class method has precedence in case of conflicts.
See Also: - classNameDecodedForArchiveClassName:, + decodeClassName:asClassName:
- (id)initForReadingWithData:(NSData
*)data
See Also: - systemVersion
- (BOOL)isAtEnd
- (NSZone *)objectZone
See Also: - setObjectZone:
- (void)replaceObject:(id)object
withObject:(id)newObject
- (void)setObjectZone:(NSZone
*)zone
nil
,
or if this method is never invoked, the default zone will be used,
as given by NSDefaultMallocZone()
.See Also: - objectZone
- (unsigned)systemVersion
The version numbers aren't the usual release designations (such as 2.0 or 3.1). By convention, version numbers under 1000 refer to early versions of the system that didn't conform to the OpenStep specification.