Contents

encode(_:)

Encodes an object.

Declaration

func encode(_ object: Any?)

Discussion

NSCoder’s implementation simply invokes encodeValue(ofObjCType: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.

See Also

Encoding General Data