Codable Feature in Xcode 9 and later
- Simple Codable
- Nested Codable
- Customize CodingKey
- Error Handling
- Customiz Codable
- Class Inheritance
- Coding Strategies
- Usage Such as Alamofire
Codable
in Playground
Theses Playgrounds represent how to use codable
in your project.
we going to learn Codable
and find this awesome feature
The Steps, we walk through in, contain below items:
- first, we create a simple json string and convert it to Swift DataTypes such
Struct
,Class
and etc. - second, we create nested json object string and covert into Nested Objects
- third, we customize
CodingKey
when our json string has customekey
named - 4th, we make a mistake on decoding then we learn how to use
catch
decoding or encdoing error - 5th, we jump into
Encodable
andDecodable
Protocol and how to override theses methods to customize encoding and decoding or create a custom validation whichCodable
errors do not invole it. - 6th, we defind base class and a class which inherite from base. Then we implement
Codable
method and how to send encoding or decoding container to base class - 7th, we walk into Encoding or Decoding stratiges such as convert date string into
Date
in decoding and etc. - 8th and last, we accept a awesome challenge which use
Codable
in our project or create decodable response or encodable request in Alamofire
Session Resources
-
Presentation Slides (PDF)
-
The video of session are in
Watch the WWDC session introducing the Codable WWDC Video