Up

NSCoder class reference

Authors

Andrew Kachites McCallum (mccallum@gnu.ai.mit.edu)
Adam Fedor (fedor@boulder.colorado.edu)

Version: 1.42

Date: 2005/02/22 11:22:43

Copyright: (C) 1995, 1996 Free Software Foundation, Inc.


Contents -

  1. Software documentation for the NSCoder class
  2. Software documentation for the NSCoder(GNUstep) category

Software documentation for the NSCoder class

NSCoder : NSObject

Declared in:
Foundation/NSCoder.h
Standards:

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.

Method summary

allowsKeyedCoding 

- (BOOL) allowsKeyedCoding;
Subclasses should override this method.

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: 

- (BOOL) containsValueForKey: (NSString*)aKey;
Subclasses should override this method.

Returns a class indicating whether an encoded value corresponding to aKey exists.


decodeArrayOfObjCType: count: at: 

- (void) decodeArrayOfObjCType: (const char*)type count: (unsigned)count at: (void*)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: 

- (BOOL) decodeBoolForKey: (NSString*)aKey;
Subclasses should override this method.

Returns a boolean value associated with aKey. This value must previously have been encoded using -encodeBool:forKey:


decodeBytesForKey: returnedLength: 

- (const uint8_t*) decodeBytesForKey: (NSString*)aKey returnedLength: (unsigned*)alength;
Subclasses should override this method.

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: 

- (void*) decodeBytesWithReturnedLength: (unsigned*)l;

Retrieve bytes directly from archive.


decodeDataObject 

- (NSData*) decodeDataObject;

Decode an instance of NSData .


decodeDoubleForKey: 

- (double) decodeDoubleForKey: (NSString*)aKey;
Subclasses should override this method.

Returns a double value associated with aKey. This value must previously have been encoded using -encodeDouble:forKey: or -encodeFloat:forKey:


decodeFloatForKey: 

- (float) decodeFloatForKey: (NSString*)aKey;
Subclasses should override this method.

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: 

- (int32_t) decodeInt32ForKey: (NSString*)aKey;
Subclasses should override this method.

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: 

- (int64_t) decodeInt64ForKey: (NSString*)aKey;
Subclasses should override this method.

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: 

- (int) decodeIntForKey: (NSString*)aKey;
Subclasses should override this method.

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.


decodeObject 

- (id) 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: 

- (id) decodeObjectForKey: (NSString*)aKey;
Subclasses should override this method.

Returns an object value associated with aKey. This value must previously have been encoded using -encodeObject:forKey: or -encodeConditionalObject:forKey:


decodePoint 

- (NSPoint) decodePoint;

Decodes a point structure.


decodePropertyList 

- (id) decodePropertyList;

Decodes a property list from the archive previously stored through a call to -encodePropertyList: .


decodeRect 

- (NSRect) decodeRect;

Decodes a rectangle structure.


decodeSize 

- (NSSize) decodeSize;

Decodes a size structure.


decodeValueOfObjCType: at: 

- (void) decodeValueOfObjCType: (const char*)type at: (void*)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: ,...

- (void) decodeValuesOfObjCTypes: (const char*)types,...;

Multiple version of -decodeValueOfObjCType:at: .


encodeArrayOfObjCType: count: at: 

- (void) encodeArrayOfObjCType: (const char*)type count: (unsigned)count at: (const void*)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: forKey: 

- (void) encodeBool: (BOOL)aBool forKey: (NSString*)aKey;
Subclasses should override this method.

Encodes aBool and associates the encoded value with aKey.


encodeBycopyObject: 

- (void) encodeBycopyObject: (id)anObject;

Can be ignored.


encodeByrefObject: 

- (void) encodeByrefObject: (id)anObject;

Can be ignored.


encodeBytes: length: 

- (void) encodeBytes: (void*)d length: (unsigned)l;

Stores bytes directly into archive.


encodeBytes: length: forKey: 

- (void) encodeBytes: (const uint8_t*)aPointer length: (unsigned)length forKey: (NSString*)aKey;
Subclasses should override this method.

Encodes the data of the specified length and pointed to by aPointer, and associates the encoded value with aKey.


encodeConditionalObject: 

- (void) encodeConditionalObject: (id)anObject;

Encode object if it is/will be encoded unconditionally by this coder, otherwise store a nil.


encodeConditionalObject: forKey: 

- (void) encodeConditionalObject: (id)anObject forKey: (NSString*)aKey;
Subclasses should override this method.

Encodes anObject and associates the encoded value with aKey, but only if anObject has already been encoded using -encodeObject:forKey:


encodeDataObject: 

- (void) encodeDataObject: (NSData*)data;

Encode an instance of NSData .


encodeDouble: forKey: 

- (void) encodeDouble: (double)aDouble forKey: (NSString*)aKey;
Subclasses should override this method.

Encodes aDouble and associates the encoded value with aKey.


encodeFloat: forKey: 

- (void) encodeFloat: (float)aFloat forKey: (NSString*)aKey;
Subclasses should override this method.

Encodes aFloat and associates the encoded value with aKey.


encodeInt32: forKey: 

- (void) encodeInt32: (int32_t)anInteger forKey: (NSString*)aKey;
Subclasses should override this method.

Encodes anInteger and associates the encoded value with aKey.


encodeInt64: forKey: 

- (void) encodeInt64: (int64_t)anInteger forKey: (NSString*)aKey;
Subclasses should override this method.

Encodes anInteger and associates the encoded value with aKey.


encodeInt: forKey: 

- (void) encodeInt: (int)anInteger forKey: (NSString*)aKey;
Subclasses should override this method.

Encodes anInteger and associates the encoded value with aKey.


encodeObject: 

- (void) encodeObject: (id)anObject;

Encodes a generic object. This will usually result in an [<NSCoding>-encodeWithCoder:] message being sent to anObject so it can encode itself.


encodeObject: forKey: 

- (void) encodeObject: (id)anObject forKey: (NSString*)aKey;
Subclasses should override this method.

Encodes anObject and associates the encoded value with aKey.


encodePoint: 

- (void) encodePoint: (NSPoint)point;

Encodes a point structure.


encodePropertyList: 

- (void) encodePropertyList: (id)plist;

Encodes a property list by calling [NSSerializer -serializePropertyList:], then encoding the resulting NSData object.


encodeRect: 

- (void) encodeRect: (NSRect)rect;

Encodes a rectangle structure.


encodeRootObject: 

- (void) encodeRootObject: (id)rootObject;

Store object and objects it refers to in archive (i.e., complete object graph).


encodeSize: 

- (void) encodeSize: (NSSize)size;

Encodes a size structure.


encodeValueOfObjCType: at: 

- (void) encodeValueOfObjCType: (const char*)type at: (const void*)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: ,...

- (void) encodeValuesOfObjCTypes: (const char*)types,...;

Multiple version of -encodeValueOfObjCType:at: .


objectZone 

- (NSZone*) objectZone;

Returns zone being used to allocate memory for decoded objects.


setObjectZone: 

- (void) setObjectZone: (NSZone*)zone;

Sets zone to use for allocating memory for decoded objects.


systemVersion 

- (unsigned int) 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: 

- (unsigned int) versionForClassName: (NSString*)className;

Returns current version of class (when encoding) or version of decoded class (decoded). Version comes from [NSObject -getVersion].


Software documentation for the NSCoder(GNUstep) category

NSCoder(GNUstep)

Declared in:
Foundation/NSCoder.h
Standards:

GNUstep extensions to NSCoder , supporting compatibility with libObjects.

Method summary

decodeArrayOfObjCType: count: at: withName: 

- (void) decodeArrayOfObjCType: (const char*)type count: (unsigned)count at: (void*)buf withName: (id*)name;

Description forthcoming.


decodeIndent 

- (void) decodeIndent;

Description forthcoming.


decodeObjectAt: withName: 

- (void) decodeObjectAt: (id*)anObject withName: (id*)name;

Description forthcoming.


decodeValueOfCType: at: withName: 

- (void) decodeValueOfCType: (const char*)type at: (void*)buf withName: (id*)name;

Description forthcoming.


decodeValueOfObjCType: at: withName: 

- (void) decodeValueOfObjCType: (const char*)type at: (void*)buf withName: (id*)name;

Description forthcoming.


encodeArrayOfObjCType: count: at: withName: 

- (void) encodeArrayOfObjCType: (const char*)type count: (unsigned)count at: (const void*)buf withName: (id)name;

Description forthcoming.


encodeIndent 

- (void) encodeIndent;

Description forthcoming.


encodeObjectAt: withName: 

- (void) encodeObjectAt: (id*)anObject withName: (id)name;

Description forthcoming.


encodeValueOfCType: at: withName: 

- (void) encodeValueOfCType: (const char*)type at: (const void*)buf withName: (id)name;

Description forthcoming.


encodeValueOfObjCType: at: withName: 

- (void) encodeValueOfObjCType: (const char*)type at: (const void*)buf withName: (id)name;

Description forthcoming.



Up