Generic Instance Method


Returns a property list that represents an encoded version of the value you supply.


func encode<Value>(_ value: Value) throws -> Data where Value : Encodable



The value to encode as a property list.


If there's a problem encoding the value you supply, this method throws an error based on the type of problem:

  • The value fails to encode, or contains a nested value that fails to encode—this method throws the corresponding error.

  • The value can't be encoded as a property list—this method throws the EncodingError.invalidValue(_:_:) error.

See Also



Creates a new, reusable property list encoder with the default formatting settings.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software