Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover Page
Title Page
Copyright Page
About the Authors
About the Technical Reviewer
About the Illustrator
Brief Contents
Contents in Detail
Acknowledgments
Introduction
Who Should Read This Book?
What’s in This Book?
The Companion Website
Have Fun!
Part 1: Xcode and Swift
1 Hello, World!
Installing Xcode, Your Code Editor
Your First App!
Introducing the Storyboard
Adding User Interface Elements with the Object Library
Saving Your Work
Running the App on a Real Device
What You Learned
2 Learning to Code in a Playground
Constants and Variables
When to Use Constants vs. Variables
Naming Constants and Variables
Data Types
Declaring Data Types
Common Data Types
Type Inference
Transforming Data Types with Casting
Operators
Order of Operations
Ordering Operations with Parentheses
Compound Assignment Operators
What You Learned
3 Making Choices
Boolean Expressions
Is Equal and Is Not Equal
Greater Than and Less Than
Compound Boolean Expressions
Conditional Statements
if Statements
switch Statements
What You Learned
4 Writing Code That Loops
Open the Debug Area
Looping Through Ranges and Collections with for-in
Say Hello!
Say Good Morning!
Testing Conditions with while Loops
Guess My Number
Shrink Away
Which Loop to Use?
Nesting and Scope
Nesting Blocks of Code
Constant and Variable Scope
What You Learned
5 Keeping Your Programs Safe with Optionals
What Is an Optional?
Creating Optionals
Unwrapping Optionals
A Special Kind of Operator: ??
What You Learned
6 Storing Collections in Dictionaries and Arrays
Keeping Things in Order with Arrays
Using Mutable and Immutable Arrays
Using Type Inference
Accessing Items in an Array
Watching the Range
Adding Items to an Array
Combining Arrays
Removing Items from an Array
Replacing Items in an Array
Using Array Properties
Looping Over an Array
Dictionaries Are Key!
Initializing a Dictionary
Accessing Values in a Dictionary
Adding Items to a Dictionary
Removing Items from a Dictionary
Replacing Items in a Dictionary
Using Dictionary Properties
Looping Over a Dictionary
What You Learned
7 Functions are a Party, and You’re Invited
In with the Input, Out with the Output
Writing a Custom Function
Functions Do Even More with Input Parameters
Making Party Invitations
Inviting All Your Friends at Once
Messaging Your Guests
Argument Labels
Adding a Custom Argument Label
Removing an Argument Label
Return Values
Which Is the Bigger Box?
Conditional Returns
What You Learned
8 Custom Classes and Structs
Making a Class
Writing a Class Definition
Storing Information in Properties
Creating an Instance of a Class
Accessing the Properties of a Class
Customizing Each Cake with Initializers
Adding a Birthday Greeting Method
Writing a Helper Method
A Special Property Called self
Class Inheritance
Creating a Superclass
Creating a Subclass
Detecting the Data Type by Typecasting
Refining the Data Type by Downcasting
Value Types and Reference Types
Using Structs
What You Learned
Part 2: Birthday Tracker
9 Creating Buttons and Screens on the Storyboard
An Outline of Your App
Creating a New Xcode Project
Adding the App Icon
Displaying Your Friends’ Birthdays
Adding the Table View Controller
Adding the Navigation Controller
Adding a Button
Setting Up Control Inputs and Labels
Adding Your Friends’ Names and Birthdays
Making Your App Look Perfect on Every Device with Auto Layout
Adding Save and Cancel Buttons
What You Learned
10 Adding a Birthday Class and Handling User Input
The Birthday Class
Creating a New File
Writing the Birthday Class
Programming User Input
Creating the Add Birthday View Controller
Connecting Code to the Input Controls
Connecting Your Code to the Storyboard
Setting a Maximum Birthdate
Saving a Birthday
Hooking Up the Save Button
Reading Text from a Text Field
Getting a Date from a Date Picker
Creating a Birthday
Adding the Cancel Button
What You Learned
11 Displaying Birthdays
Making the Birthday List
Creating the Birthdays Table View Controller
Adding Cells to the Table View
Setting Up the Birthdays Table View Controller
Displaying Birthdays in a Table View
Putting It All Together
Delegation
Connecting the Two Controllers by Setting a Delegate
What You Learned
12 Saving Birthdays
Storing Birthdays in a Database
The Birthday Entity
The Birthday Attributes
The Application Delegate
Code Cleanup
Adding More Features to Our App
Alphabetizing Birthdays
Removing Birthdays
What You Learned
13 Getting Birthday Notifications
The User Notifications Framework
Registering for Local Notifications
Scheduling a Notification
Removing a Notification
What You Learned
Part 3: Schoolhouse Skateboarder
14 Setting the Stage
Where Do I Get Art and Sound Effects?
Making Games with Xcode’s SpriteKit
Creating the Game Project
Adding Images
The Scenery: Displaying a Background Image
How It Will Be Played: Screen Orientation
Sizing Images for Different Screen Resolutions
What You Learned
15 Making Schoolhouse Skateboarder a Real Game
Our Hero, the Skateboarder
Creating a Skater Sprite Class
Importing SpriteKit
Adding Custom Properties to the Skater Class
Creating an Instance of the Skater in the Scene
Setting Up the Skater
Seeing the Skater on the Screen
Understanding SpriteKit’s Debugging Information
Hittin’ the Bricks
Creating Sidewalk Bricks
Updating Sidewalk Bricks
Filling the Screen with Bricks
Leaving Gaps to Jump
The Game Loop
Tracking the Update Time
Calculating Elapsed Time for Each Update
Adjusting Scroll Speed Using the Elapsed Time
Updating the Bricks
Up, Up, and Away—Making the Skater Jump
Using a Tap Gesture Recognizer
Simulating Gravity in a Simple Way
Checking for Landings
What You Learned
16 Using the Spritekit Physics Engine
Setting Up the Physics World
Physics Bodies
Giving Shape to the Physics Bodies
Setting Properties of Physics Bodies
Giving the skater Sprite a Physics Body
Adding Physics Bodies to Bricks
Contacts and Collisions
Handling Contacts and Collisions
Responding to Contacts
Applying Forces to Physics Bodies
Starting and Ending the Game
Starting the Game
Ending the Game
What You Learned
17 Adjusting Difficulty, Collecting Gems, and Keeping Score
Speeding Things Up
Adding Multilevel Platforms
Defining Multiple Brick Levels
Changing How Bricks Spawn
Adding Gems to Collect
Spawning and Tracking the Gems
Deciding When to Spawn a Gem
Removing Gems
Updating Gems
Collecting Gems
Adding Scoring and Labels
Creating Labels
Tracking the Score
Updating Labels
Updating the Player’s Score
Making the Gems Valuable
Tracking the High Score
Tweaking the Gameplay
What You Learned
18 Game State, Menus, Sounds, and Special Effects
Tracking Game State
Adding a Menu System
Creating the MenuLayer Class
Displaying the Menu Layers When Needed
Removing the Menu Layer
Making Sounds
Adding the Sound Files
Playing the Sounds at the Right Time
Shooting Sparks
What You Learned
Resources
Troubleshooting Errors
Apple Documentation
Xcode Keyboard Shortcuts
iOS Simulator Keyboard Shortcuts
Xcode Versions
Index
← Prev
Back
Next →
← Prev
Back
Next →