This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.
PDF The popular standard, used most often with the free Adobe® Reader® software.
This 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:
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
Number Types 16
From Objective-C to Swift 17
2 Collecting Your Data: Arrays and Dictionaries 31
Using Arrays 31
Modifying Arrays 33
Using Dictionaries 36
3 Making Things Happen: Functions 43
Defining Functions 44
More on Parameters 47
4 Structuring Code: Enums, Structs, and Classes 57
5 SpriteKit 75
Introducing SpriteKit 75
Creating a Game 76
6 Reusable Code: Closures 93
What Are Closures? 93
Closures in Other Languages 94
How Closures Work and Why They’re Awesome 95
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
8 Protocols 129
Writing Your First Protocol 129
Animizable and Humanizable 134
Protocols as Types 138
Protocols in Collections 139
Optional Chaining 146
9 Becoming Flexible with Generics 153
The Problem That Generics Solve 153
10 Games with SpriteKit 163
The Game 163
The Setup 163
Tour the Code 164
The Game 164
11 Making Games with Physics 187
Making a Physics-Based Game 187
12 Making Apps with UIKit 205
Application Types 205