Book Image

Mastering Swift 5.3 - Sixth Edition

By : Jon Hoffman
Book Image

Mastering Swift 5.3 - Sixth Edition

By: Jon Hoffman

Overview of this book

Over the years, Mastering Swift has proven itself among developers as a popular choice for an in-depth and practical guide to the Swift programming language. This sixth edition comes with the latest features, an overall revision to align with Swift 5.3, and two new chapters on building swift from source and advanced operators. From the basics of the language to popular features such as concurrency, generics, and memory management, this in-depth guide will help you develop your expertise and mastery of the language. As you progress, you will gain practical insights into some of the most sophisticated elements in Swift development, including protocol extensions, error handling, and closures. The book will also show you how to use and apply them in your own projects. In later chapters, you will understand how to use the power of protocol-oriented programming to write flexible and easier-to-manage code in Swift. Finally, you will learn how to add the copy-on-write feature to your custom value types, along with understanding how to avoid memory management issues caused by strong reference cycles. By the end of this Swift book, you will have mastered the Swift 5.3 language and developed the skills you need to effectively use its features to build robust applications.
Table of Contents (23 chapters)
21
Other Books You May Enjoy
22
Index

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, Swift Documentation and Installing Swift, will introduce you to the swift.org and swiftdoc.org sites and how the Swift development process works. We will go through the complete process of building Swift from source and installing it on both Linux and Mac platforms.

Chapter 3, Learning about Variables, Constants, Strings, and Operators, will introduce variables and constants in Swift and explain when to use them. There will be brief overviews of the most common variable types, with examples on how to use them. We'll conclude this chapter with some examples of how to use the most common operators in the Swift language.

Chapter 4, Optional Types, will explain what optional types really are, and the various ways to unwrap them. For a developer who is just learning Swift, optional types can be one of the more confusing concepts to learn.

Chapter 5, Using Swift Collections, will explain Swift's array, set, and dictionary collection types and show examples on how to use them.

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

Chapter 7, Functions, is all about functions in Swift. We will show how to define and properly use them.

Chapter 8, Classes, Structures, and Protocols, is dedicated to Swift's classes, structures, and protocols. We'll look at what makes them similar and how they differ.

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

Chapter 10, Protocol-Oriented Design, will cover the best practices of protocol-oriented design with Swift.

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

Chapter 12, Error Handling and Availability, will cover error handling in depth as well as the availability feature.

Chapter 13, Custom Subscripting, will discuss how we can use custom subscripts in our classes, structures, and enumerations.

Chapter 14, Working with Closures, will show how to define and use closures in our code. This chapter concludes with a section on how to avoid strong reference cycles with closures.

Chapter 15, Advanced and Custom Operators, will show how to use bitwise and overflow operators. We will also look at how we can create custom operators.

Chapter 16, 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.

Chapter 17, Custom Value Types, will cover some advanced techniques that you can use in your applications, like copy-on-write and implementing the Equatable protocol.

Chapter 18, Memory Management, will cover topics like how Automatic Reference Counting (ARC) works, how much faster value types are as compared to reference types, how strong retain cycles work, and how weak and strong references compare.

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

Chapter 20, 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.