Up

NSCoder class reference

Authors

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

Version: 37003

Date: 2013-08-22 09:44:54 -0600 (Thu, 22 Aug 2013)

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

Software documentation for the NSCoder class

NSCoder : NSObject

Declared in:
Foundation/NSCoder.h
Availability: OpenStep

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;
Availability: MacOS-X 10.0.0

Subclasses must 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;
Availability: MacOS-X 10.0.0

Subclasses must override this method.
Returns a class indicating whether an encoded value corresponding to aKey exists.

decodeArrayOfObjCType: count: at: 

- (void) decodeArrayOfObjCType: (const char*)type count: (NSUInteger)count at: (void*)address;
Availability: OpenStep

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;
Availability: MacOS-X 10.0.0

Subclasses must 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: (NSUInteger*)alength;
Availability: MacOS-X 10.0.0

Subclasses must 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: (NSUInteger*)l;
Availability: OpenStep

Retrieve bytes directly from archive.

decodeDataObject 

- (NSData*) decodeDataObject;
Availability: OpenStep

Decode an instance of NSData .

decodeDoubleForKey: 

- (double) decodeDoubleForKey: (NSString*)aKey;
Availability: MacOS-X 10.0.0

Subclasses must 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;
Availability: MacOS-X 10.0.0

Subclasses must 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;
Availability: MacOS-X 10.0.0

Subclasses must 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;
Availability: MacOS-X 10.0.0

Subclasses must 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;
Availability: MacOS-X 10.0.0

Subclasses must 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.

decodeIntegerForKey: 

- (NSInteger) decodeIntegerForKey: (NSString*)key;
Availability: MacOS-X 10.5.0

Subclasses must override this method.
Decodes an NSInteger associated with the key.

decodeObject 

- (id) decodeObject;
Availability: OpenStep

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;
Availability: MacOS-X 10.0.0

Subclasses must 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;
Availability: OpenStep

Decodes a point structure.

decodePropertyList 

- (id) decodePropertyList;
Availability: OpenStep

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

decodeRect 

- (NSRect) decodeRect;
Availability: OpenStep

Decodes a rectangle structure.

decodeSize 

- (NSSize) decodeSize;
Availability: OpenStep

Decodes a size structure.

decodeValueOfObjCType: at: 

- (void) decodeValueOfObjCType: (const char*)type at: (void*)address;
Availability: OpenStep

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,...;
Availability: OpenStep

Multiple version of -decodeValueOfObjCType:at: .

encodeArrayOfObjCType: count: at: 

- (void) encodeArrayOfObjCType: (const char*)type count: (NSUInteger)count at: (const void*)array;
Availability: OpenStep

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;
Availability: MacOS-X 10.0.0

Subclasses must override this method.
Encodes aBool and associates the encoded value with aKey.

encodeBycopyObject: 

- (void) encodeBycopyObject: (id)anObject;
Availability: OpenStep

Can be ignored.

encodeByrefObject: 

- (void) encodeByrefObject: (id)anObject;
Availability: OpenStep

Can be ignored.

encodeBytes: length: 

- (void) encodeBytes: (void*)d length: (NSUInteger)l;
Availability: OpenStep

Stores bytes directly into archive.

encodeBytes: length: forKey: 

- (void) encodeBytes: (const uint8_t*)aPointer length: (NSUInteger)length forKey: (NSString*)aKey;
Availability: MacOS-X 10.0.0

Subclasses must 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;
Availability: OpenStep

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;
Availability: MacOS-X 10.0.0

Subclasses must 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;
Availability: OpenStep

Encode an instance of NSData .

encodeDouble: forKey: 

- (void) encodeDouble: (double)aDouble forKey: (NSString*)aKey;
Availability: MacOS-X 10.0.0

Subclasses must override this method.
Encodes aDouble and associates the encoded value with aKey.

encodeFloat: forKey: 

- (void) encodeFloat: (float)aFloat forKey: (NSString*)aKey;
Availability: MacOS-X 10.0.0

Subclasses must override this method.
Encodes aFloat and associates the encoded value with aKey.

encodeInt32: forKey: 

- (void) encodeInt32: (int32_t)anInteger forKey: (NSString*)aKey;
Availability: MacOS-X 10.0.0

Subclasses must override this method.
Encodes 32 bit integer and associates the encoded value with aKey.

encodeInt64: forKey: 

- (void) encodeInt64: (int64_t)anInteger forKey: (NSString*)aKey;
Availability: MacOS-X 10.0.0

Subclasses must override this method.
Encodes a 64 bit integer and associates the encoded value with aKey.

encodeInt: forKey: 

- (void) encodeInt: (int)anInteger forKey: (NSString*)aKey;
Availability: MacOS-X 10.0.0

Subclasses must override this method.
Encodes an int and associates the encoded value with aKey.

encodeInteger: forKey: 

- (void) encodeInteger: (NSInteger)anInteger forKey: (NSString*)key;
Availability: MacOS-X 10.5.0

Subclasses must override this method.
Encodes an NSInteger and associates the encoded value with key.

encodeObject: 

- (void) encodeObject: (id)anObject;
Availability: OpenStep

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;
Availability: MacOS-X 10.0.0

Subclasses must override this method.
Encodes anObject and associates the encoded value with aKey.

encodePoint: 

- (void) encodePoint: (NSPoint)point;
Availability: OpenStep

Encodes a point structure.

encodePropertyList: 

- (void) encodePropertyList: (id)plist;
Availability: OpenStep

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

encodeRect: 

- (void) encodeRect: (NSRect)rect;
Availability: OpenStep

Encodes a rectangle structure.

encodeRootObject: 

- (void) encodeRootObject: (id)rootObject;
Availability: OpenStep

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

encodeSize: 

- (void) encodeSize: (NSSize)size;
Availability: OpenStep

Encodes a size structure.

encodeValueOfObjCType: at: 

- (void) encodeValueOfObjCType: (const char*)type at: (const void*)address;
Availability: OpenStep

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,...;
Availability: OpenStep

Multiple version of -encodeValueOfObjCType:at: .

objectZone 

- (NSZone*) objectZone;
Availability: OpenStep

Returns zone being used to allocate memory for decoded objects.

setObjectZone: 

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

Sets zone to use for allocating memory for decoded objects.

systemVersion 

- (unsigned int) systemVersion;
Availability: OpenStep

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: 

- (NSInteger) versionForClassName: (NSString*)className;
Availability: OpenStep

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


Up