From the course: iOS App Development: RESTful Web Services

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Codable protocol is two protocols

Codable protocol is two protocols - iOS Tutorial

From the course: iOS App Development: RESTful Web Services

Start my 1-month free trial

Codable protocol is two protocols

- [Instructor] Now we want to look at the Codable protocol new with Swift 4. The Codable protocol is actually two protocols put together, Encodable and Decodable, for the round trip of taking objects, storing them into data, and the reverse: having data and converting that into instances of objects. It's similar in concept to the serialization functionality in Java. It's not quite the same, but the concepts are similar as far as converting data back and forth to something that can be stored or sent to another process. If you've used earlier versions of Swift or Objective-C, you may have used NSCoder or Archiver. Codable replaces that functionality to something that's a little bit more streamlined and more commonly used with JSON. The SDK provides encoders and decoders specifically for JSON data that makes it pretty smooth in converting data from a RESTful JSON API. You can learn more about this at Apple's documentation site for Swift, specifically the Codable protocol. It shows you…

Contents