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,Classand etc. - second, we create nested json object string and covert into Nested Objects
- third, we customize
CodingKeywhen our json string has customekeynamed - 4th, we make a mistake on decoding then we learn how to use
catchdecoding or encdoing error - 5th, we jump into
EncodableandDecodableProtocol and how to override theses methods to customize encoding and decoding or create a custom validation whichCodableerrors do not invole it. - 6th, we defind base class and a class which inherite from base. Then we implement
Codablemethod 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
Datein decoding and etc. - 8th and last, we accept a awesome challenge which use
Codablein 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