CoderProtocol
public protocol CoderProtocol
CoderProtocol API
-
Protocol function to encode the received object to Data
Note: The encodable object has to conform to Apple’s Codable protocol
Throws
Declaration
Swift
func encode<Value>(_ value: Value) throws -> Data where Value : Encodable
Parameters
value
Object to encode, which conforms to Codable protocol
Return Value
encoded Data object
-
Protocol function to decode the reqested data to original format
Note: The decodable object has to conform to Apple’s Codable protocol before encoding
Throws
Declaration
Swift
func decode<T>(_ type: T.Type, from data: Data) throws -> T where T : Decodable
Parameters
type
the Codable type itself. example: “String.self”
data
the Data to decode
Return Value
decoded object