Contents

encodeConditional(_:forKey:)

Encodes a reference to the given object only if it is encoded unconditionally elsewhere in the payload (previously, or in the future).

Declaration

mutating func encodeConditional<T>(_ object: T, forKey key: KeyedEncodingContainer<K>.Key) throws where T : AnyObject, T : Encodable

Parameters

  • object:

    The object to encode.

  • key:

    The key to associate the object with.

Discussion

For encoders which don’t support this feature, the default implementation encodes the given object unconditionally.