SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
This PDF will be accessible from your Account page after purchase and requires PDF reading software, such as Acrobat® Reader®.
The eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
Get started fast with Swift 2 programming for iOS and OS X
Learning Swift 2 Programming is a fast-paced, hands-on introduction to writing production-quality iOS and OS X apps with Apple’s programming language. Written for developers with experience in any modern language, this book explains Swift simply and clearly, using relevant examples that solve realistic problems.
Author Jacob Schatz’s popular YouTube video tutorials have already helped thousands of Apple developers get started with Swift. Now, he helps you take full advantage of Swift’s advanced design, remarkable performance, and streamlined development techniques.
Step by step, you’ll move from basic syntax through advanced features such as closures and generics—discovering helpful tips and tricks along the way. After you’ve mastered Swift’s building blocks and learned about its key innovations, a full section of case studies walks you through building complete apps from scratch.
Learn how to:
Introduction 1
1 Getting Your Feet Wet: Variables, Constants, and Loops 5
Building Blocks of Swift 6
Merging Variables into a String 10
Optionals: A Gift to Unwrap 11
Tuples 15
Number Types 16
From Objective-C to Swift 17
Summary 29
2 Collecting Your Data: Arrays and Dictionaries 31
Using Arrays 31
Modifying Arrays 33
Using Dictionaries 36
Summary 41
3 Making Things Happen: Functions 43
Defining Functions 44
More on Parameters 47
Summary 55
4 Structuring Code: Enums, Structs, and Classes 57
Enums 58
Structs 61
Summary 74
5 SpriteKit 75
Introducing SpriteKit 75
Creating a Game 76
Summary 92
6 Reusable Code: Closures 93
What Are Closures? 93
Closures in Other Languages 94
How Closures Work and Why They’re Awesome 95
Summary 107
7 Creating Your Own Syntax: Subscripts and Advanced Operators 109
Writing Your First Subscript 110
Bits and Bytes with Advanced Operators 113
Customizing Operators 120
Making Your Own Operators 122
Bits and Bytes in Real Life 123
Summary 127
8 Protocols 129
Writing Your First Protocol 129
Animizable and Humanizable 134
Delegation 136
Protocols as Types 138
Protocols in Collections 139
Optional Chaining 146
Summary 151
9 Becoming Flexible with Generics 153
The Problem That Generics Solve 153
Summary 162
10 Games with SpriteKit 163
The Game 163
The Setup 163
Tour the Code 164
The Game 164
Summary 185
11 Making Games with Physics 187
Making a Physics-Based Game 187
Summary 204
12 Making Apps with UIKit 205
Application Types 205
Summary 218
Index 219