Instance Method
encode(_:)
iOS 8.0+
iPadOS 8.0+
Mac Catalyst 8.0+
macOS 10.10+
tvOS 9.0+
watchOS 2.0+
Returns a property list that represents an encoded version of the value you supply.
func encode<Value>(_ value: Value) throws -> Data where Value : Encodable
Parameters
valueThe value to encode.
Return Value
A new Data value containing the encoded property list data.
Discussion
Throws
EncodingError.invalidValue if a non-conforming floating-point value is encountered during encoding, and the encoding strategy is .throw.
Throws
An error if any value throws an error during encoding.