Type Method

version

Returns the version number assigned to the class.

Declaration

+ (NSInteger)version;

Return Value

The version number assigned to the class.

Discussion

If no version has been set, the default is 0.

Version numbers are needed for decoding or unarchiving, so older versions of an object can be detected and decoded correctly.

Caution should be taken when obtaining the version from within an NSCoding protocol or other methods. Use the class name explicitly when getting a class version number:

version = [MyClass version];

Don’t simply send version to the return value of class—a subclass version number may be returned instead.

Special Considerations

The version number applies to NSArchiver/NSUnarchiver, but not to NSKeyedArchiver/NSKeyedUnarchiver. A keyed archiver does not encode class version numbers.

See Also

Archiving

- awakeAfterUsingCoder:

Overridden by subclasses to substitute another object in place of the object that was decoded and subsequently received this message.

classForArchiver

The class to substitute for the receiver's own class during archiving.

classForCoder

Overridden by subclasses to substitute a class other than its own during coding.

classForKeyedArchiver

Subclasses to substitute a new class for instances during keyed archiving.

+ classFallbacksForKeyedArchiver

Overridden to return the names of classes that can be used to decode objects if their class is unavailable.

+ classForKeyedUnarchiver

Overridden by subclasses to substitute a new class during keyed unarchiving.

classForPortCoder

Class to substitute for the receiver in distribution encoding.

Deprecated
- replacementObjectForArchiver:

Overridden by subclasses to substitute another object for itself during archiving.

Deprecated
- replacementObjectForCoder:

Overridden by subclasses to substitute another object for itself during encoding.

- replacementObjectForKeyedArchiver:

Overridden by subclasses to substitute another object for itself during keyed archiving.

- replacementObjectForPortCoder:

Overridden by subclasses to substitute another object or a copy for itself during distribution encoding.

Deprecated
+ setVersion:

Sets the receiver's version number.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software