New in Swift 4, Codable radically improves the way you work with JSON and other representations of data.
Chances are that your app interacts with a web service in some capacity. And when it does, the data you’re getting back is most likely JSON. Codable provides the best way to map those JSON payloads to your Swift models. Thanks to automatic code synthesis from the compiler, tasks that used to take hours of engineering and hundreds of lines of boilerplate can now be done in a few moments — often with little to no additional code.
This book offers a comprehensive look at all aspects of Codable, starting with the basics, and exploring a variety of advanced topics through engaging example projects.
Reading this book, you'll:
Learn how to navigate corner cases and shape your Codable model to whatever representation comes your way.
- Adapt Codable to the iTunes Search web API to build the core functionality of a music store app, and get a productivity boost from some command-line tricks.
- Build the core of an in-flight ordering app backed by User Defaults, the easiest way to persist data across app launches.
- Make part of a luggage scanning app using QR codes and Core Data, and learn the best way to use Core Data with external data sources.
- Implement a custom encoder for the MessagePack format from scratch, and come away with a deep understanding of binary serialization formats.
Each chapter starts with a delightful illustration from Lauren Mendez (@littleloboart) and ends with a series of challenges for you to take your understanding to the next level. There are also plenty of sample code projects provided as Playground files.
About Flight School
Flight School is a new book series for Swift developers. Each month, we'll explore an essential part of iOS, macOS, and Swift development through concise, focused books.
Our guides offer practical knowledge that will help you be more productive and effective as a developer. We strive to create resources that are engaging, informative, and accessible to a wide audience. Whether you've been working with Swift from the very beginning or just getting your start now, we promise that you'll find something to love in everything we make.
About the Author
Mattt (@mattt) is a writer and developer in Portland, Oregon. He spent the last 3 years at Apple as a technical writer, contributing to The Swift Programming Language, Swift Package Manager, and Swift.org. Before that, Mattt founded NSHipster, a weekly publication for iOS and macOS developers, and maintained several open source libraries, including AFNetworking and Alamofire.
About the Illustrator
Lauren Mendez (@littleloboart) is an illustrator, designer, and storyteller living in Vancouver, Washington. Her delightful and expressive illustrations in Flight School evoke the spirit of flight in its golden age, inviting readers to reach new heights of understanding.