▶Book Description
Swift is the definitive language of Apple development today. It’s a vital part of any iOS and OS X developer’s skillset, helping them to build the most impressive and popular apps on the App Store—the sort of apps that are essential to iPhone and iPad users every day. With version 3.0, the Swift team have added new features to improve the development experience—making it easier to get the results you want and customers expect.
Inside, you’ll find the key features of Swift 3.0 and quickly learn how to use the newest updates to your development advantage. From Objective-C interoperability to ARC, to closures and concurrency, this advanced Swift guide will develop your expertise and make you more fluent in this vital programming language.
We give you in-depth knowledge of some of the most sophisticated elements of Swift development including protocol extensions, error-handling, design patterns, and concurrency, and guide you on how to use and apply them in your own projects. You'll see how even the most challenging design patterns and programming techniques can be used to write cleaner code and to build more performant iOS and OS X applications.
By the end of this book, you’ll have a handle on effective design patterns and techniques, which means you’ll soon be writing better iOS and OS X applications with a new level of sophistication and control.
▶What You Will Learn
- Dive into the core components of Swift 3.0, including operators, collections, control flow, and functions
- Create and use classes, structures, and enums
- Understand object-oriented Swift and see how to tackle inheritance, protocols, and extensions
- Develop a practical understanding of subscripts, optionals, and closures
- See how to use the new protocol extension and error handling features of Swift 3.0
- Add concurrency to your applications using Grand Central Dispatch
▶Key Features
- Discover the new features and improvements to Swift 3
- Get to grips with advanced design patterns and techniques to write smarter, cleaner Swift code
- Become a more fluent Swift developer and build powerful, impressive iOS and OS X applications.
▶Who This Book Is For
This book is for developers who want to dive into the newest version of Swift.
If you are a developer that learns best by looking at, and working with code, then this book is for you. A basic understanding of Apple's tools is beneficial but not mandatory.
▶Style and approach
Packed with practical examples that show you how to put the concepts you learn into practice quickly, we’ll takes you through some of the most advanced and sophisticated elements of the language in a practical and actionable way. You can also download the code to use yourself
▶What this book covers
- Chapter 1, Taking the First Steps with Swift, shows you how to start and use Playgrounds to experiment with Swift programming. We will also cover the basic Swift language syntax and discuss proper language styles.
- Chapter 2, Learning About Variables, Constants, Strings, and Operators, will show how to use variables and constants in Swift. We will also look at the various data types and how to use operators in Swift.
- Chapter 3, Using Swift Collections and the Tuple Type, will look at how we can use the Swift collection types to store related data. These collection types are the dictionary and array types. We will also look at how we can use the Cocoa and Foundation data types in Swift.
- Chapter 4, Control Flow and Functions, will cover control flow and functions in Swift. It is essential to understand the concepts in this chapter before going on. Every application that we write, beyond the simple Hello World applications, will rely very heavily on the control flow statements and functions.
- Chapter 5, Classes and Structures, 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. We'll close this chapter out by looking at memory management in Swift.
- Chapter 6, 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 7, 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 (POP) book.
- Chapter 8, Writing Safer Code with Availability and Error Handling, will look at Swift’s errorhandling features. This feature is really important for writing safe code. While we are not required to use this feature in our custom types, it does give us a uniform manner to handle and respond to the error. Apple has also started to use this error handling in their frameworks. It is recommended that we use error handling in our code.
- Chapter 9, 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. We can also define custom subscripts for our classes, structures, and enumerations.
- Chapter 10, Using Optional Types, will explain what optional types really are, what the various ways to unwrap them are, and optional chaining. For a developer who is just learning Swift, optional types can be one of the most confusing items to learn.
- Chapter 11, Working with Generics, will explain how Swift implements generics. Generics allow us to write very flexible and reusable code that avoids duplication.
- Chapter 12, Working with Closures, will teach us how to define and use closures in our code. Closures in Swift are similar to blocks in Objective-C except that they have a much cleaner and easier way of using syntax. We will conclude this chapter with a section on how to avoid strong reference cycles with closures.
- Chapter 13, Using Mix and Match, will explain mix and match and demonstrate how we can include Swift code in our Objective-C projects and Objective-C code in our Swift projects. With all of the apps and frameworks written in Objective-C, it is important to allow Swift and Objective-C code to work together.
- 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, 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 a style guide, since most enterprises have style guides for the various languages that they develop in.
- Chapter 16, Swift's Core Libraries, will be a chapter on using the Swift core libraries, including reading/writing files, network primitives, and JSON parsing.
- Chapter 17, 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.