Book Image

Mastering iOS 12 Programming - Third Edition

By : Donny Wals
Book Image

Mastering iOS 12 Programming - Third Edition

By: Donny Wals

Overview of this book

The iOS development environment has significantly matured, and with Apple users spending more money in the App Store, there are plenty of development opportunities for professional iOS developers. However, the journey to mastering iOS development and the new features of iOS 12 is not straightforward. This book will help you make that transition smoothly and easily. With the help of Swift 4.2, you’ll not only learn how to program for iOS 12, but also how to write efficient, readable, and maintainable Swift code that maintains industry best practices. Mastering iOS 12 Programming will help you build real-world applications and reflect the real-world development flow. You will also find a mix of thorough background information and practical examples, teaching you how to start implementing your newly gained knowledge. By the end of this book, you will have got to grips with building iOS applications that harness advanced techniques and make best use of the latest and greatest features available in iOS 12.
Table of Contents (35 chapters)
Title Page
Copyright and Credits
Packt Upsell

Chapter 6. Writing Flexible Code with Protocols and Generics

If you spend enough time around a Swift developer, you'll hear them mention protocol-oriented programming. Apple introduced this programming paradigm at WWDC 2015 in a talk that generated a lot of buzz among developers. Suddenly, we learned that thinking in classes and hierarchies leads to code that's hard to maintain, modify, and expand. The talk introduced a way of programming that is focused on what an object can do instead of explicitly caring about what an object is.

This chapter is packed with complex and interesting information that is essential if you want to write beautiful Swift code.  You will learn how you can make use of the powers of POP, and it will show you why it's an essential feature of Swift. You'll start off with some simple use cases, and then you'll take a deep dive into its associated types and generic protocols.

Understanding patterns and recognizing situations in which a protocol, protocol extension, or...