NSCoder Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.0 and later.
Companion guide
Declared in
NSCoder.h
NSGeometry.h
Related sample code

Overview

The NSCoder abstract class declares the interface used by concrete subclasses to transfer objects and other Objective-C data items between memory and some other format. This capability provides the basis for archiving (where objects and data items are stored on disk) and distribution (where objects and data items are copied between different processes or threads). The concrete subclasses provided by Foundation for these purposes are NSArchiver, NSUnarchiver, NSKeyedArchiver, NSKeyedUnarchiver, and NSPortCoder. Concrete subclasses of NSCoder are referred to in general as coder classes, and instances of these classes as coder objects (or simply coders). A coder object that can only encode values is referred to as an encoder object, and one that can only decode values as a decoder object.

NSCoder operates on objects, scalars, C arrays, structures, and strings, and on pointers to these types. It does not handle types whose implementation varies across platforms, such as union, void *, function pointers, and long chains of pointers. A coder object stores object type information along with the data, so an object decoded from a stream of bytes is normally of the same class as the object that was originally encoded into the stream. An object can change its class when encoded, however; this is described in Archives and Serializations Programming Guide.

Subclassing Notes

For details of how to create a subclass of NSCoder, see “Subclassing NSCoder” in Archives and Serializations Programming Guide.

Tasks

Testing Coder

Encoding Data

Decoding Data

Secure Coding

Getting Version Information

Managing Zones

Instance Methods

allowedClasses

Get the current set of coded classes that allow secure coding.

- (NSSet *)allowedClasses
Return Value

The allowed classes.

Discussion

Secure coders check this set of allowed classes before decoding objects, and all objects must implement the NSSecureCoding protocol.

Availability
  • Available in OS X v10.8 and later.
Declared In
NSCoder.h

allowsKeyedCoding

Returns a Boolean value that indicates whether the receiver supports keyed coding of objects.

- (BOOL)allowsKeyedCoding
Discussion

The default implementation returns NO. Concrete subclasses that support keyed coding, such as NSKeyedArchiver, need to override this method to return YES.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

containsValueForKey:

Returns a Boolean value that indicates whether an encoded value is available for a string.

- (BOOL)containsValueForKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

The string is passed as key.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

decodeArrayOfObjCType:count:at:

Decodes an array of count items, whose Objective-C type is given by itemType.

- (void)decodeArrayOfObjCType:(const char *)itemType count:(NSUInteger)count at:(void *)address
Discussion

The items are decoded into the buffer beginning at address, which must be large enough to contain them all. itemType must contain exactly one type code. NSCoder’s implementation invokes decodeValueOfObjCType:at: to decode the entire array of items.

This method matches an encodeArrayOfObjCType:count:at: message used during encoding.

For information on creating an Objective-C type code suitable for itemType, see “Type Encodings”.

Special Considerations

You should not use this method to decode C arrays of Objective-C objects. For historical reasons, returned objects will have an additional ownership reference which you can only relinquish using CFRelease.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

decodeBoolForKey:

Decodes and returns a boolean value that was previously encoded with encodeBool:forKey: and associated with the string key.

- (BOOL)decodeBoolForKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Related Sample Code
Declared In
NSCoder.h

decodeBytesForKey:returnedLength:

Decodes a buffer of data that was previously encoded with encodeBytes:length:forKey: and associated with the string key.

- (const uint8_t *)decodeBytesForKey:(NSString *)key returnedLength:(NSUInteger *)lengthp
Discussion

The buffer’s length is returned by reference in lengthp. The returned bytes are immutable. Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

decodeBytesWithReturnedLength:

Decodes a buffer of data whose types are unspecified.

- (void *)decodeBytesWithReturnedLength:(NSUInteger *)numBytes
Discussion

NSCoder’s implementation invokes decodeValueOfObjCType:at: to decode the data as a series of bytes, which this method then places into a buffer and returns. The buffer’s length is returned by reference in numBytes. If you need the bytes beyond the scope of the current @autoreleasepool block, you must copy them.

This method matches an encodeBytes:length: message used during encoding.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

decodeDataObject

Decodes and returns an NSData object that was previously encoded with encodeDataObject:. Subclasses must override this method.

- (NSData *)decodeDataObject
Discussion

The implementation of your overriding method must match the implementation of your encodeDataObject: method. For example, a typical encodeDataObject: method encodes the number of bytes of data followed by the bytes themselves. Your override of this method must read the number of bytes, create an NSData object of the appropriate size, and decode the bytes into the new NSData object.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

decodeDoubleForKey:

Decodes and returns a double value that was previously encoded with either encodeFloat:forKey: or encodeDouble:forKey: and associated with the string key.

- (double)decodeDoubleForKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Related Sample Code
Declared In
NSCoder.h

decodeFloatForKey:

Decodes and returns a float value that was previously encoded with encodeFloat:forKey: or encodeDouble:forKey: and associated with the string key.

- (float)decodeFloatForKey:(NSString *)key
Discussion

If the value was encoded as a double, the extra precision is lost. If the encoded real value does not fit into a float, the method raises an NSRangeException. Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Related Sample Code
Declared In
NSCoder.h

decodeInt32ForKey:

Decodes and returns a 32-bit integer value that was previously encoded with encodeInt:forKey:, encodeInteger:forKey:, encodeInt32:forKey:, or encodeInt64:forKey: and associated with the string key.

- (int32_t)decodeInt32ForKey:(NSString *)key
Discussion

If the encoded integer does not fit into a 32-bit integer, the method raises an NSRangeException. Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

decodeInt64ForKey:

Decodes and returns a 64-bit integer value that was previously encoded with encodeInt:forKey:, encodeInteger:forKey:, encodeInt32:forKey:, or encodeInt64:forKey: and associated with the string key.

- (int64_t)decodeInt64ForKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

decodeIntegerForKey:

Decodes and returns an NSInteger value that was previously encoded with encodeInt:forKey:, encodeInteger:forKey:, encodeInt32:forKey:, or encodeInt64:forKey: and associated with the string key.

- (NSInteger)decodeIntegerForKey:(NSString *)key
Discussion

If the encoded integer does not fit into the NSInteger size, the method raises an NSRangeException. Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.5 and later.
Related Sample Code
Declared In
NSCoder.h

decodeIntForKey:

Decodes and returns an int value that was previously encoded with encodeInt:forKey:, encodeInteger:forKey:, encodeInt32:forKey:, or encodeInt64:forKey: and associated with the string key.

- (int)decodeIntForKey:(NSString *)key
Discussion

If the encoded integer does not fit into the default integer size, the method raises an NSRangeException. Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

decodeObject

Decodes an Objective-C object that was previously encoded with any of the encode...Object: methods.

- (id)decodeObject
Discussion

NSCoder’s implementation invokes decodeValueOfObjCType:at: to decode the object data.

Subclasses may need to override this method if they override any of the corresponding encode...Object: methods. For example, if an object was encoded conditionally using the encodeConditionalObject: method, this method needs to check whether the object had actually been encoded.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

decodeObjectForKey:

Decodes and returns an Objective-C object that was previously encoded with encodeObject:forKey: or encodeConditionalObject:forKey: and associated with the string key.

- (id)decodeObjectForKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Related Sample Code
Declared In
NSCoder.h

decodeObjectOfClass:forKey:

Decodes an object for the key, restricted to the specified class.

- (id)decodeObjectOfClass:(Class)aClass forKey:(NSString *)key
Parameters
aClass

The expect class type.

key

The coder key.

Return Value

The decoded object.

Discussion

If the coder responds YES to requiresSecureCoding, then an exception will be thrown if the class to be decoded does not implement NSSecureCoding or is not isKindOfClass: of aClass.

If the coder responds NO to requiresSecureCoding, then the class argument is ignored and no check of the class of the decoded object is performed, exactly as if decodeObjectForKey: had been called.

Availability
  • Available in OS X v10.8 and later.
Declared In
NSCoder.h

decodeObjectOfClasses:forKey:

Decodes an object for the key, restricted to the specified classes.

- (id)decodeObjectOfClasses:(NSSet *)classes forKey:(NSString *)key
Parameters
classes

A set of the expected classes.

key

The coder key.

Return Value

The decoded object.

Discussion

The class of the object may be any class in the classes set, or a subclass of any class in the set. Otherwise, the behavior is the same as decodeObjectOfClass:forKey:.

Availability
  • Available in OS X v10.8 and later.
Declared In
NSCoder.h

decodePoint

Decodes and returns an NSPoint structure that was previously encoded with encodePoint:.

- (NSPoint)decodePoint
Availability
  • Available in OS X v10.0 and later.
Declared In
NSGeometry.h

decodePointForKey:

Decodes and returns an NSPoint structure that was previously encoded with encodePoint:forKey:.

- (NSPoint)decodePointForKey:(NSString *)key
Availability
  • Available in OS X v10.2 and later.
Declared In
NSGeometry.h

decodePropertyList

Decodes a property list that was previously encoded with encodePropertyList:.

- (id)decodePropertyList
Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

decodePropertyListForKey:

Returns a decoded property list for the specified key.

- (id)decodePropertyListForKey:(NSString *)key
Parameters
key

The coder key.

Return Value

A decoded object containing a property list.

Discussion

This method calls decodeObjectOfClasses:forKey: with a set allowing only property list types.

Availability
  • Available in OS X v10.8 and later.
Declared In
NSCoder.h

decodeRect

Decodes and returns an NSRect structure that was previously encoded with encodeRect:.

- (NSRect)decodeRect
Availability
  • Available in OS X v10.0 and later.
Declared In
NSGeometry.h

decodeRectForKey:

Decodes and returns an NSRect structure that was previously encoded with encodeRect:forKey:.

- (NSRect)decodeRectForKey:(NSString *)key
Availability
  • Available in OS X v10.2 and later.
Declared In
NSGeometry.h

decodeSize

Decodes and returns an NSSize structure that was previously encoded with encodeSize:.

- (NSSize)decodeSize
Availability
  • Available in OS X v10.0 and later.
Declared In
NSGeometry.h

decodeSizeForKey:

Decodes and returns an NSSize structure that was previously encoded with encodeSize:forKey:.

- (NSSize)decodeSizeForKey:(NSString *)key
Availability
  • Available in OS X v10.2 and later.
Declared In
NSGeometry.h

decodeValueOfObjCType:at:

Decodes a single value, whose Objective-C type is given by valueType.

- (void)decodeValueOfObjCType:(const char *)valueType at:(void *)data
Discussion

valueType must contain exactly one type code, and the buffer specified by data must be large enough to hold the value corresponding to that type code. For information on creating an Objective-C type code suitable for valueType, see “Type Encodings”.

Subclasses must override this method and provide an implementation to decode the value. In your overriding implementation, decode the value into the buffer beginning at data.

This method matches an encodeValueOfObjCType:at: message used during encoding.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

decodeValuesOfObjCTypes:

Decodes a series of potentially different Objective-C types.

- (void)decodeValuesOfObjCTypes:(const char *)valueTypes, ...
Discussion

valueTypes is a single C string containing any number of type codes. The variable arguments to this method consist of one or more pointer arguments, each of which specifies the buffer in which to place a single decoded value. For each type code in valueTypes, you must specify a corresponding pointer argument whose buffer is large enough to hold the decoded value.

This method matches an encodeValuesOfObjCTypes: message used during encoding.

NSCoder’s implementation invokes decodeValueOfObjCType:at: to decode individual types. Subclasses that implement the decodeValueOfObjCType:at: method do not need to override this method.

For information on creating Objective-C type codes suitable for valueTypes, see “Type Encodings”.

Special Considerations

You should not use this method to decode Objective-C objects. See decodeArrayOfObjCType:count:at: for more details.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeArrayOfObjCType:count:at:

Encodes an array of count items, whose Objective-C type is given by itemType.

- (void)encodeArrayOfObjCType:(const char *)itemType count:(NSUInteger)count at:(const void *)address
Discussion

The values are encoded from the buffer beginning at address. itemType must contain exactly one type code. NSCoder’s implementation invokes encodeValueOfObjCType:at: to encode the entire array of items. Subclasses that implement the encodeValueOfObjCType:at: method do not need to override this method.

This method must be matched by a subsequent decodeArrayOfObjCType:count:at: message.

For information on creating an Objective-C type code suitable for itemType, see “Type Encodings”.

Special Considerations

You should not use this method to encode C arrays of Objective-C objects. See decodeArrayOfObjCType:count:at: for more details.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeBool:forKey:

Encodes boolv and associates it with the string key.

- (void)encodeBool:(BOOL)boolv forKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Related Sample Code
Declared In
NSCoder.h

encodeBycopyObject:

Can be overridden by subclasses to encode object so that a copy, rather than a proxy, is created upon decoding.

- (void)encodeBycopyObject:(id)object
Discussion

NSCoder’s implementation simply invokes encodeObject:.

This method must be matched by a corresponding decodeObject message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeByrefObject:

Can be overridden by subclasses to encode object so that a proxy, rather than a copy, is created upon decoding.

- (void)encodeByrefObject:(id)object
Discussion

NSCoder’s implementation simply invokes encodeObject:.

This method must be matched by a corresponding decodeObject message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeBytes:length:

Encodes a buffer of data whose types are unspecified.

- (void)encodeBytes:(const void *)address length:(NSUInteger)numBytes
Discussion

The buffer to be encoded begins at address, and its length in bytes is given by numBytes.

This method must be matched by a corresponding decodeBytesWithReturnedLength: message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeBytes:length:forKey:

Encodes a buffer of data, bytesp, whose length is specified by lenv, and associates it with the string key.

- (void)encodeBytes:(const uint8_t *)bytesp length:(NSUInteger)lenv forKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

encodeConditionalObject:

Can be overridden by subclasses to conditionally encode object, preserving common references to that object.

- (void)encodeConditionalObject:(id)object
Discussion

In the overriding method, object should be encoded only if it’s unconditionally encoded elsewhere (with any other encode...Object: method).

This method must be matched by a subsequent decodeObject message. Upon decoding, if object was never encoded unconditionally, decodeObject returns nil in place of object. However, if object was encoded unconditionally, all references to object must be resolved.

NSCoder’s implementation simply invokes encodeObject:.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeConditionalObject:forKey:

Conditionally encodes a reference to objv and associates it with the string key only if objv has been unconditionally encoded with encodeObject:forKey:.

- (void)encodeConditionalObject:(id)objv forKey:(NSString *)key
Discussion

Subclasses must override this method if they support keyed coding.

The encoded object is decoded with the decodeObjectForKey: method. If objv was never encoded unconditionally, decodeObjectForKey: returns nil in place of objv.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

encodeDataObject:

Encodes a given NSData object.

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

Subclasses must override this method.

This method must be matched by a subsequent decodeDataObject message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeDouble:forKey:

Encodes realv and associates it with the string key.

- (void)encodeDouble:(double)realv forKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Related Sample Code
Declared In
NSCoder.h

encodeFloat:forKey:

Encodes realv and associates it with the string key.

- (void)encodeFloat:(float)realv forKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Related Sample Code
Declared In
NSCoder.h

encodeInt32:forKey:

Encodes the 32-bit integer intv and associates it with the string key.

- (void)encodeInt32:(int32_t)intv forKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

encodeInt64:forKey:

Encodes the 64-bit integer intv and associates it with the string key.

- (void)encodeInt64:(int64_t)intv forKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

encodeInt:forKey:

Encodes intv and associates it with the string key.

- (void)encodeInt:(int)intv forKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSCoder.h

encodeInteger:forKey:

Encodes a given NSInteger and associates it with a given key.

- (void)encodeInteger:(NSInteger)intv forKey:(NSString *)key
Discussion

Subclasses must override this method if they perform keyed coding.

Availability
  • Available in OS X v10.5 and later.
Related Sample Code
Declared In
NSCoder.h

encodeObject:

Encodes object.

- (void)encodeObject:(id)object
Discussion

NSCoder’s implementation simply invokes encodeValueOfObjCType:at: to encode object. Subclasses can override this method to encode a reference to object instead of object itself. For example, NSArchiver detects duplicate objects and encodes a reference to the original object rather than encode the same object twice.

This method must be matched by a subsequent decodeObject message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeObject:forKey:

Encodes the object objv and associates it with the string key.

- (void)encodeObject:(id)objv forKey:(NSString *)key
Discussion

Subclasses must override this method to identify multiple encodings of objv and encode a reference to objv instead. For example, NSKeyedArchiver detects duplicate objects and encodes a reference to the original object rather than encode the same object twice.

Availability
  • Available in OS X v10.2 and later.
Related Sample Code
Declared In
NSCoder.h

encodePoint:

Encodes point.

- (void)encodePoint:(NSPoint)point
Discussion

NSCoder’s implementation invokes encodeValueOfObjCType:at: to encode point.

This method must be matched by a subsequent decodePoint message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSGeometry.h

encodePoint:forKey:

Encodes point and associates it with the string key.

- (void)encodePoint:(NSPoint)point forKey:(NSString *)key
Availability
  • Available in OS X v10.2 and later.
Declared In
NSGeometry.h

encodePropertyList:

Encodes the property list aPropertyList.

- (void)encodePropertyList:(id)aPropertyList
Discussion

NSCoder’s implementation invokes encodeValueOfObjCType:at: to encode aPropertyList.

This method must be matched by a subsequent decodePropertyList message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeRect:

Encodes rect.

- (void)encodeRect:(NSRect)rect
Discussion

NSCoder’s implementation invokes encodeValueOfObjCType:at: to encode rect.

This method must be matched by a subsequent decodeRect message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSGeometry.h

encodeRect:forKey:

Encodes rect and associates it with the string key.

- (void)encodeRect:(NSRect)rect forKey:(NSString *)key
Availability
  • Available in OS X v10.2 and later.
Declared In
NSGeometry.h

encodeRootObject:

Can be overridden by subclasses to encode an interconnected group of Objective-C objects, starting with rootObject.

- (void)encodeRootObject:(id)rootObject
Discussion

NSCoder’s implementation simply invokes encodeObject:.

This method must be matched by a subsequent decodeObject message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeSize:

Encodes size.

- (void)encodeSize:(NSSize)size
Discussion

NSCoder’s implementation invokes encodeValueOfObjCType:at: to encode size.

This method must be matched by a subsequent decodeSize message.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSGeometry.h

encodeSize:forKey:

Encodes size and associates it with the string key.

- (void)encodeSize:(NSSize)size forKey:(NSString *)key
Availability
  • Available in OS X v10.2 and later.
Declared In
NSGeometry.h

encodeValueOfObjCType:at:

Must be overridden by subclasses to encode a single value residing at address, whose Objective-C type is given by valueType.

- (void)encodeValueOfObjCType:(const char *)valueType at:(const void *)address
Discussion

valueType must contain exactly one type code.

This method must be matched by a subsequent decodeValueOfObjCType:at: message.

For information on creating an Objective-C type code suitable for valueType, see “Type Encodings”.

Special Considerations

You should not use this method to encode of Objective-C objects. See decodeArrayOfObjCType:count:at: for more details.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

encodeValuesOfObjCTypes:

Encodes a series of values of potentially differing Objective-C types.

- (void)encodeValuesOfObjCTypes:(const char *)valueTypes, ...
Discussion

valueTypes is a C string containing any number of type codes. The variable arguments to this method consist of one or more pointer arguments, each of which specifies a buffer containing the value to be encoded. For each type code in valueTypes, you must specify a corresponding pointer argument.

This method must be matched by a subsequent decodeValuesOfObjCTypes: message.

NSCoder’s implementation invokes encodeValueOfObjCType:at: to encode individual types. Subclasses that implement the encodeValueOfObjCType:at: method do not need to override this method. However, subclasses that provide a more efficient approach for encoding a series of values may override this method to implement that approach.

For information on creating Objective-C type codes suitable for valueTypes, see “Type Encodings”.

Special Considerations

You should not use this method to encode Objective-C objects. See decodeArrayOfObjCType:count:at: for more details.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

objectZone

This method is present for historical reasons and has no effect.

- (NSZone *)objectZone
Discussion

NSCoder’s implementation returns the default memory zone, as given by NSDefaultMallocZone().

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

requiresSecureCoding

Returns whether the coder requires secure coding.

- (BOOL)requiresSecureCoding
Return Value

YES if this coder requires secure coding; NO otherwise.

Discussion

Secure coders check a set of allowed classes before decoding objects, and all objects must implement the NSSecureCoding protocol.

Availability
  • Available in OS X v10.8 and later.
Declared In
NSCoder.h

setObjectZone:

This method is present for historical reasons and has no effect.

- (void)setObjectZone:(NSZone *)zone
Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

systemVersion

During encoding, this method should return the system version currently in effect.

- (unsigned)systemVersion
Discussion

During decoding, this method should return the version that was in effect when the data was encoded.

By default, this method returns the current system version, which is appropriate for encoding but not for decoding. Subclasses that implement decoding must override this method to return the system version of the data being decoded.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h

versionForClassName:

This method is present for historical reasons and is not used with keyed archivers.

- (NSInteger)versionForClassName:(NSString *)className
Return Value

The version in effect for the class named className or NSNotFound if no class named className exists.

Discussion

The version number does apply not to NSKeyedArchiver/NSKeyedUnarchiver. A keyed archiver does not encode class version numbers.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSCoder.h