In just 24 lessons of one hour or less, Sams Teach Yourself Swift in 24 Hours, Second Edition, will teach you how to build next-generation OS X and iOS apps with Apple’s Swift 2 programming language. This book’s straightforward, step-by-step approach helps you quickly master Swift 2’s core concepts, structure, and syntax and use Swift to write safe, powerful, modern code. In just a few hours you’ll be applying features such as extensions, closures, protocols, and generics. Every lesson builds on what you’ve already learned, giving you a rock-solid foundation for real-world success.
Step-by-step instructions carefully walk you through the most common Swift 2 programming tasks.
Practical, hands-on examples show you how to apply what you learn.
Quizzes and exercises help you test your knowledge and stretch your skills.
Notes and tips point out shortcuts and solutions.
Learn how to...
- Get started with Swift 2.0’s Xcode 7 development environment
- Master Swift’s fundamental data types
- Use operators to change, assign, combine, check, or verify values
- Retain data and preferences in memory with arrays, sets, and dictionaries
- Control program flow, modify execution paths, and iterate code
- Perform complex actions concisely with Swift 2.0’s improved functions
- Work with higher-order functions and closures
- Harness the power of structs, enums, classes, and class inheritance
- Take advantage of Swift’s advanced memory allocation and references
- Use protocols to define behavior and explore Protocol-Oriented Programming
- Add type functionality with extensions
- Smoothly handle errors
- Leverage the power of generics to create flexible and reusable code
- Interoperate with Objective-C code
- Get started with Functional Programming approaches and thinking functionally
Table of Contents
1 Introducing the Swift Development Environment
2 Learning Swift’s Fundamental Data Types
3 Using Operators in Swift
4 Working with Collection Types
5 Controlling Program Flow with Conditionals
6 Understanding Optional Values
7 Iterating Code with Loops
8 Using Functions to Perform Actions
9 Understanding Higher Order Functions and Closures
10 Learning About Structs and Classes
11 Implementing Class Inheritance
12 Harnessing the Power of Enums
13 Customizing Initializers of Classes, Structs, and Enums
14 Digging Deeper with Properties
15 Adding Advanced Type Functionality
16 Understanding Memory Allocation and References
17 Using Protocols to Define Behavior
18 Using Extensions to Add Type Functionality
19 Working with Optional Chaining
20 Introducing Generics
21 Understanding Protocol-Oriented Programming
22 Handling Errors
23 Adding Interoperability with Objective-C
24 Functional Thinking in Swift