Generic Instance Method

container(keyedBy:)

Returns an encoding container appropriate for holding multiple values keyed by the given key type.

Required.

Declaration

func container<Key>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> where Key : CodingKey

Parameters

type

The key type to use for the container.

Return Value

A new keyed encoding container.

Discussion

You must use only one kind of top-level encoding container. This method must not be called after a call to unkeyedContainer() or after encoding a value through a call to singleValueContainer()