Book Image

Mastering Swift 5 - Fifth Edition

By : Jon Hoffman
Book Image

Mastering Swift 5 - Fifth Edition

By: Jon Hoffman

Overview of this book

Over the years, the Mastering Swift book has established itself amongst developers as a popular choice as an in-depth and practical guide to the Swift programming language. The latest edition is fully updated and revised to cover the new version: Swift 5. Inside this book, you'll find the key features of Swift 5 easily explained with complete sets of examples. From the basics of the language to popular features such as concurrency, generics, and memory management, this definitive guide will help you develop your expertise and mastery of the Swift language. Mastering Swift 5, Fifth Edition will give you an in-depth knowledge of some of the most sophisticated elements in Swift development, including protocol extensions, error handling, and closures. It will guide you on how to use and apply them in your own projects. Later, you'll see how to leverage the power of protocol-oriented programming to write flexible and easier-to-manage code. You will also see how to add the copy-on-write feature to your custom value types and how to avoid memory management issues caused by strong reference cycles.
Table of Contents (20 chapters)

What this book covers

Chapter 1, Taking the First Steps with Swift, will introduce you to the Swift programming language and discuss what inspired Apple to create Swift. We'll also go over the basic syntax of Swift and how to use Playgrounds to experiment and test Swift code.

Chapter 2, Learning about Variables, Constants, Strings and Operators will introduce you to variables and constants in Swift and when to use them. There will be brief overviews of the most common variable types with examples on how to use them. This chapter concludes by showing examples of how to use the most common operators in the Swift language.

Chapter 3, Optional Types, will explain what optional types really are, what are the various ways to unwrap them, and optional chaining. For a developer who is just learning Swift, optional types can be one of the more confusing items to learn. This chapter will give you a good understanding of what Optionals are and how to use them.

Chapter 4, Using Swift Collections will explain Swift's array, set, and dictionary collection types and show examples on how to use them. By the end of this chapter you will have a full understanding of the collection types in Swift.

Chapter 5, Control Flow, will show you how to use Swift's control flow statements. These include looping, conditional, and control transfer statements.

Chapter 6, Functions, will show you how to define and use functions in your applications.

Chapter 7, Classes, Structures, and Protocols is dedicated to Swift's classes and structures. We'll look at what makes them similar and what makes them different. We'll also look at access controls and object-oriented design.

Chapter 8, Using Protocols and Protocol Extensions will cover both protocols and protocol extensions in detail since protocols are very important to the Swift language, and having a solid understanding of them will help us write flexible and reusable code

Chapter 9, Protocol Oriented Design will cover the best practices of protocol oriented design with Swift. It will be a brief overview of what is covered in my protocol-oriented programming book.

Chapter 10, Generics will explain how Swift implements generics. Generics allow us to write very flexible and reusable code that avoids duplication

Chapter 11, Availability and Error Handling will cover error handling in depth as well as the availability feature. Error handling is the process of responding to and recovering from error conditions

Chapter 12, Custom Subscripting will discuss how we can use custom subscripts in our classes, structures, and enumerations. Subscripts in Swift can be used to access elements in a collection.

Chapter 13, Working with Closures will teach us how to define and use closures in our code. We will conclude this chapter with a section on how to avoid strong reference cycles with closures.

Chapter 14, Concurrency and Parallelism in Swift will show how to use both grand central dispatch and operation queues to add concurrency and parallelism to our applications. Understanding and knowing how to add concurrency and parallelism to our apps can significantly enhance the user experience.

Chapter 15, Custom Types will cover some advance techniques that the reader can use in their applications like copy-on-write and implementing the equatible protocol. The information covered in this chapter is also covered in the Swift protocol-oriented programming book published by Packt.

Chapter 16, Memory Management will cover how Automatic Reference Counting (ARC) works, why value types are faster than reference types, strong retain cycles, weak vs strong references.

Chapter 17, Swift Formatting and Style Guider will define a style guide for the Swift language that can be used as a template for enterprise developers who need to create a style guide.

Chapter 18, Adopting Design Patterns in Swift will show you how to implement some of the more common design patterns in Swift. A design pattern identifies a common software development problem and provides a strategy for dealing with it. The information covered in this chapter is also covered in the Swift protocol-oriented programming book published by Packt.