# NSCoder class reference

mccallum@gnu.ai.mit.edu
fedor@boulder.colorado.edu
1995, 1996 Free Software Foundation, Inc.
Software documentation for the NSCoder class
Foundation/NSCoder.h

Top-level class defining methods for use when archiving (encoding) objects to a byte array or file, and when restoring (decoding) objects. Generally only subclasses of this class are used directly - NSArchiver , NSUnarchiver , NSKeyedArchiver , NSKeyedUnarchiver , or NSPortCoder.

`NSPortCoder` is used within the distributed objects framework. For archiving to/from disk, the Keyed... classes are preferred for new implementations, since they provide greater forward/backward compatibility in the face of class changes.

allowsKeyedCoding
Returns a flag indicating whether the receiver supported keyed coding. the default implementation returns `NO`. Subclasses supporting keyed coding must override this to return `YES`.
containsValueForKey:
aKey
Returns a class indicating whether an encoded value corresponding to aKey exists.
decodeArrayOfObjCType:
type
count:
count
at:
address
Decodes array of count structures or objects of given type, which may be obtained through the ' `@encode(...)` ' compile-time operator. Usually this is used for primitives though it can be used for objects as well. Objects will be retained and you must release them.
decodeBoolForKey:
aKey
Returns a boolean value associated with aKey. This value must previously have been encoded using -encodeBool:forKey:
decodeBytesForKey:
aKey
returnedLength:
alength
Returns a pointer to a byte array associated with aKey.
Returns the length of the data in aLength.
This value must previously have been encoded using -encodeBytes:length:forKey:
decodeBytesWithReturnedLength:
l
Retrieve bytes directly from archive.
decodeDataObject
Decode an instance of NSData .
decodeDoubleForKey:
aKey
Returns a double value associated with aKey. This value must previously have been encoded using -encodeDouble:forKey: or -encodeFloat:forKey:
decodeFloatForKey:
aKey
Returns a float value associated with aKey. This value must previously have been encoded using -encodeFloat:forKey: or -encodeDouble:forKey:
Precision may be lost (or an exception raised if the value will not fit in a float) if the value was encoded using -encodeDouble:forKey: ,
decodeInt32ForKey:
aKey
Returns a 32-bit integer value associated with aKey. This value must previously have been encoded using -encodeInt:forKey: , -encodeInt32:forKey: , or -encodeInt64:forKey: .
An exception will be raised if the value does not fit in a 32-bit integer.
decodeInt64ForKey:
aKey
Returns a 64-bit integer value associated with aKey. This value must previously have been encoded using -encodeInt:forKey: , -encodeInt32:forKey: , or -encodeInt64:forKey: .
decodeIntForKey:
aKey
Returns an integer value associated with aKey. This value must previously have been encoded using -encodeInt:forKey: , -encodeInt32:forKey: , or -encodeInt64:forKey: .
An exception will be raised if the value does not fit in an integer.
decodeIntegerForKey:
key
Decodes an NSInteger associated with the key.
decodeObject
Decodes a generic object. Usually the class will be read from the archive, an object will be created through an `alloc` call, then that class will be sent an [<NSCoding>-initWithCoder:] message.
decodeObjectForKey:
aKey
Returns an object value associated with aKey. This value must previously have been encoded using -encodeObject:forKey: or -encodeConditionalObject:forKey:
decodeObjectOfClass:
cls
forKey:
aKey
Description forthcoming.
decodeObjectOfClasses:
classes
forKey:
aKey
Description forthcoming.
decodePoint
Decodes a point structure.
decodePropertyList
Decodes a property list from the archive previously stored through a call to -encodePropertyList: .
decodeRect
Decodes a rectangle structure.
decodeSize
Decodes a size structure.
decodeValueOfObjCType:
type
at:
address
Decodes structure or object of given type, which may be obtained through the ' `@encode(...)` ' compile-time operator. Usually this is used for primitives though it can be used for objects as well, in which case you are responsible for releasing them.
decodeValuesOfObjCTypes:
types
Multiple version of -decodeValueOfObjCType:at: .
encodeArrayOfObjCType:
type
count:
count
at:
array
Encodes array of count structures or objects of given type, which may be obtained through the ' `@encode(...)` ' compile-time operator. Usually this is used for primitives though it can be used for objects as well.
encodeBool:
aBool
forKey:
aKey
Encodes aBool and associates the encoded value with aKey.
encodeBycopyObject:
anObject
Can be ignored.
encodeByrefObject:
anObject
Can be ignored.
encodeBytes:
d
length:
l
Stores bytes directly into archive.
encodeBytes:
aPointer
length:
length
forKey:
aKey
Encodes the data of the specified length and pointed to by aPointer, and associates the encoded value with aKey.
encodeConditionalObject:
anObject
Encode object if it is/will be encoded unconditionally by this coder, otherwise store a `nil`.
encodeConditionalObject:
anObject
forKey:
aKey
Encodes anObject and associates the encoded value with aKey, but only if anObject has already been encoded using -encodeObject:forKey:
encodeDataObject:
data
Encode an instance of NSData .
encodeDouble:
aDouble
forKey:
aKey
Encodes aDouble and associates the encoded value with aKey.
encodeFloat:
aFloat
forKey:
aKey
Encodes aFloat and associates the encoded value with aKey.
encodeInt32:
anInteger
forKey:
aKey
Encodes 32 bit integer and associates the encoded value with aKey.
encodeInt64:
anInteger
forKey:
aKey
Encodes a 64 bit integer and associates the encoded value with aKey.
encodeInt:
anInteger
forKey:
aKey
Encodes an int and associates the encoded value with aKey.
encodeInteger:
anInteger
forKey:
key
Encodes an NSInteger and associates the encoded value with key.
encodeObject:
anObject
Encodes a generic object. This will usually result in an [<NSCoding>-encodeWithCoder:] message being sent to anObject so it can encode itself.
encodeObject:
anObject
forKey:
aKey
Encodes anObject and associates the encoded value with aKey.
encodePoint:
point
Encodes a point structure.
encodePropertyList:
plist
Encodes a property list by calling [NSSerializer -serializePropertyList:], then encoding the resulting NSData object.
encodeRect:
rect
Encodes a rectangle structure.
encodeRootObject:
rootObject
Store object and objects it refers to in archive (i.e., complete object graph).
encodeSize:
size
Encodes a size structure.
encodeValueOfObjCType:
type
at:
address
Encodes structure or object of given type, which may be obtained through the ' `@encode(...)` ' compile-time operator. Usually this is used for primitives though it can be used for objects as well.
encodeValuesOfObjCTypes:
types
Multiple version of -encodeValueOfObjCType:at: .
objectZone
Returns zone being used to allocate memory for decoded objects.
requiresSecureCoding
Description forthcoming.
setObjectZone:
zone
Sets zone to use for allocating memory for decoded objects.
setRequiresSecureCoding:
secure
Description forthcoming.
systemVersion
Returns *Step version, which is not the release version, but a large number, by specification <1000 for pre-OpenStep. This implementation returns a number based on the GNUstep major, minor, and subminor versions.
versionForClassName:
className
Returns current version of class (when encoding) or version of decoded class (decoded). Version comes from [NSObject -getVersion].