Contents

encodeConditionalObject(_:)

An encoding method for subclasses to override to conditionally encode an object, preserving common references to it.

Declaration

func encodeConditionalObject(_ object: Any?)

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 encode(_:).

See Also

Related Documentation

Encoding General Data