Shape Shape point chapter-list Group Group Group Shape Copy 12 Shape Shape Copy 3 Shape Shape dropdown editor editor Combined Shape grid Shape Copy 4 Shape Copy 7 Shape language language Shape megaphone paperback Shape platform noun_419259-2 copy play-icon BS-Question-Rounded-Circle quotes noun_610406 stacked-books-1 stacked-books-2 Group Group Group Group Group
Update

Swift Apprentice

$59.99 4.9/5 9 reviews · Write a Review
  • Platform iOS 13
  • Language Swift 5.1
  • Editor Xcode 11

Beginning programming with Swift! This book takes you from beginner to advanced in Swift: Apple’s modern programming language for iOS.

Developer Guide

Beginner

For Beginner Developers

This book is for complete beginners to Swift and coding. No prior programming experience necessary!

This is a book for complete beginners to Apple’s new, modern programming language — Swift.

All the code in the book works inside of Xcode’s easy-to-use playgrounds. That means you can focus on core Swift language concepts, such as classes, protocols, and generics, instead of getting bogged down in the details of building apps.

This is a companion book to the iOS Apprentice; the iOS Apprentice focuses on building apps, while Swift Apprentice focuses on the Swift language itself.

We also recommend

Table of Contents

Section I: Swift Basics

1.

Expressions, Variables & Constants

This is it, your whirlwind introduction to the world of programming! You’ll begin with an overview of computers and programming, and then say hello to Swift playgrounds, which are where you’ll spend your coding time for the rest of this book. You’ll learn some basics such as code comments, arithmetic operations, constants and variables. These are some of the fundamental building blocks of any language, and Swift is no different.

2.

Types & Operations

You’ll learn about handling different types, including strings which allow you to represent text. You’ll learn about converting between types and you’ll also be introduced to type inference which makes your life as a programmer a lot simpler. You’ll learn about tuples which allow you to make your own types made up of multiple values of any type.

3.

Basic Control Flow

You’ll learn how to make decisions and repeat tasks in your programs by using syntax to control the flow. You’ll also learn about Booleans, which represent true and false values, and how you can use these to compare data.

4.

Advanced Control Flow

Continuing the theme of code not running in a straight line, you’ll learn about another loop known as the `for` loop. You’ll also learn about switch statements which are particularly powerful in Swift.

5.

Functions

Functions are the basic building blocks you use to structure your code in Swift. You’ll learn how to define functions to group your code into reusable units.

6.

Optionals

This chapter covers optionals, a special type in Swift that represents either a real value or the absence of a value. By the end of this chapter, you’ll know why you need optionals and how to use them safely.

Section II: Collection Types

7.

Arrays, Dictionaries, & Sets

Arrays are the most common collection type you’ll run into in Swift. Arrays are typed, as are regular variables and constants and store multiple values like a single list.

8.

Collection Iteration with Closures

Swift has an object you can use to break up code into reusable chunks: a closure. These are particularly important when dealing with collections.

9.

Strings

Finally, you will revisit strings, which are actually bi-directional collections of unicode characters.

Section III: Building Your Own Types

10.

Structures

This chapter introduces structures, which are the first named type you’ll learn about. Structures are types that can store named properties and define their own behaviors.

11.

Properties

In this chapter, you’ll learn about stored and computed properties, along with some tricks to deal with properties, how to monitor changes in a property’s value and delay initialization of a stored property.

12.

Methods

Methods are merely functions that reside in a structure. In this chapter, you’ll take a closer look at methods and initializers.

13.

Classes

Structures introduced you to your first named type, which lets you define your own named types. In this chapter, you’ll get acquainted with classes, which are much like structures.

14.

Advanced Classes

This chapter introduces the finer points of classes and helps you understand how you can create, use and manage complex classes.

15.

Enumerations

In this chapter, you’ll learn how enumerations work and when they’re useful. As a bonus, you’ll finally discover what an optional is under the hood.

16.

Protocols

Protocols are a type that can bridge common behaviors between structs, classes, and enums by defining an interface or template for an actual concrete type.

17.

Generics

In this chapter, you’ll learn what generics are, learn how to write your own generic code, and loop back and look at the generic types in Swift - dictionaries, arrays, and optionals - from this new perspective.

Section IV: Advanced Topics

18.

Access Control, Code Organization, & Testing

Swift gives you powerful tools for hiding complexity and organizing your code into easier to digest units. This chapter details how to do that.

19.

Custom Operators, Subscripts, & Keypaths

You’ll learn how you can define your own operators and subscripts to make your types feel even more like built-in language constructs.

20.

Pattern Matching

With pattern matching you can accomplish more — with less typing. You’ll master all of its many forms in this chapter.

21.

Error Handling

In the real world, some errors cannot be avoided. Handling them gracefully is what sets apart mediocre code from great code.

22.

Encoding & Decoding Types

You will learn about the type serialization system introduced in Swift 4 with particular emphasis on the JSON format.

23.

Memory Management

This chapter digs into the details of Swift memory management examining the relation between objects. It shows you how you avoid common leaks.

24.

Value Types & Reference Types

Value semantics have a clear advantage over reference semantics in terms of the local reasoning but can lead to inefficiency for large objects. This chapter shows you how to get the best of both worlds.

25.

Protocol-Oriented Programming

From the standard library to user authored generics, Swift is a protocol-based language. In this chapter you’ll see how to get all of the benefits associated with object-oriented programming while being able to avoid most of the difficulties.

26.

Advanced Protocols & Generics - New

Learn how to use constraints to make generic code more useful and how to hide implementation details with opaque return types.

Meet the team

Customer reviews

Swift Apprentice

Clear tuition without guesswork or confusion. Concepts that are easy to absorb.

Rob W.

Apple's documentation is great, but it lacks the gentle approach of this book. I always have the PDF open for quick lookups!

Blaise B.

As a novice developer trying to learn Swift, this series was exactly what I needed to get started. It shows you how to build actual applications that teach you many of the fundamentals of Swift.

Seth M.

Average Rating

4.9 /5

Leave a review for this product

9 reviews

Swift Apprentice

Beginning programming with Swift! This book takes you from beginner to advanced in Swift: Apple’s modern programming language for iOS.

Top