What Is Encodable in Swift

A type that can encode itself to an external representation. iOS 8.0+

What is Codable Encodable and Decodable in Swift?

Codable means they can be decoded from and encoded into another representation. Decodable means it can be decoded, but not encoded. And encodable is the opposite of that.

Why we use Codable and Decodable in Swift?

The Codable protocol in Swift is really a union of two protocols: Encodable and Decodable . These two protocols are used to indicate whether a certain struct, enum, or class, can be encoded into JSON data, or materialized from JSON data. … A lot of Swift’s built-in types already conform to Codable by default.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest