What is Codable in Swift

Needone App
1 min readAug 28, 2020

--

Codable was introduced in Swift since 4.0, which is used for encoding and decoding objects into JSON. From its definition we can see it is just the combination of Decodable and Encodable:

public typealias Codable = Decodable & Encodable

Example of using Codable:

Define a custom object with Codable:

Reference:

https://needone.app/codable-in-ios-development/

Originally published at https://needone.app on August 28, 2020.

--

--

No responses yet