Hide TOC

Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

NSCoding

Implemented by
Various Cocoa classes
Package
com.apple.cocoa.foundation
Companion guide

Overview

The NSCoding interface is adopted by classes that can be coded with an NSCoder object. Although the interface technically contains no methods, Java classes must implement the following two methods to be codable:

protected ClassName(NSCoder decoder, long token);
protected void encodeWithCoder(NSCoder encoder);

The first is a constructor method where ClassName is replaced with the name of your class. It is invoked when decoding an object. The method must invoke a similar method of its super class if the super class also implements NSCoding; otherwise, the method needs to invoke another constructor of the super class. The second method is invoked when encoding an object. The method must invoke the some method of its super class if the super class also implements NSCoding.

NSCoding is independent of Java’s own serialization protocol, java.io.Serializable. Unlike java.io.Serializable, NSCoding does not mark classes for automatic coding; instead, each class handles its own encoding and decoding operations with the methods described above.



Hide TOC


© 1997, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-24)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.