Coding iPhone Apps for Kids: A Playful Introduction to Swift

Coding iPhone Apps for Kids: A Playful Introduction to Swift

by Gloria Winquist, Matt McCarthy

Paperback

$26.96 $29.95 Save 10% Current price is $26.96, Original price is $29.95. You Save 10%.
View All Available Formats & Editions
Choose Expedited Shipping at checkout for guaranteed delivery by Thursday, October 24

Overview

Apple’s Swift is a powerful, beginner-friendly programming language that anyone can use to make cool apps for the iPhone or iPad. In Coding iPhone Apps for Kids, you’ll learn how to use Swift to write programs, even if you’ve never programmed before.

You’ll work in the Xcode playground, an interactive environment where you can play with your code and see the results of your work immediately! You’ll learn the fundamentals of programming too, like how to store data in arrays, use conditional statements to make decisions, and create functions to organize your code—all with the help of clear and patient explanations.

Once you master the basics, you’ll build a birthday tracker app so that you won’t forget anyone’s birthday and a platform game called Schoolhouse Skateboarder with animation, jumps, and more!

As you begin your programming adventure, you’ll learn how to:
–Build programs to save you time, like one that invites all of your friends to a party with just the click of a button!
–Program a number-guessing game with loops to make the computer keep guessing until it gets the right answer
–Make a real, playable game with graphics and sound effects using SpriteKit
–Challenge players by speeding up your game and adding a high-score systemWhy should serious adults have all the fun? Coding iPhone Apps for Kids is your ticket to the exciting world of computer programming.

Covers Swift 3.x and Xcode 8.x. Requires OS X 10.11 or higher.

Product Details

ISBN-13: 9781593277567
Publisher: No Starch Press
Publication date: 06/30/2017
Pages: 336
Sales rank: 720,637
Product dimensions: 6.80(w) x 9.00(h) x 1.00(d)
Age Range: 10 - 13 Years

About the Author

Gloria Winquist became hooked on iOS development in 2011 and has been programming professionally ever since. She works as an iOS developer at LumiraDx.
Matt McCarthy has released more than 20 apps as part of a two-person team, Tomato Interactive LLC. He works as a software engineer at LumiraDx.

Table of Contents

Acknowledgments xvii

Introduction xix

Who Should Read This Book? xx

What's in This Book? xx

The Companion Website xxi

Have Fun! xxi

Part 1 Xcode and Swift

1 Hello, World! 3

Installing Xcode, Your Code Editor 4

Your First App! 5

Introducing the Storyboard 9

Adding User Interface Elements with the Object Library 10

Saving Your Work 13

Running the App on a Real Device 14

What You Learned 16

2 Learning to Code in a Playground 17

Constants and Variables 19

When to Use Constants vs. Variables 21

Naming Constants and Variables 22

Data Types 22

Declaring Data Types 23

Common Data Types 24

Type Inference 25

Transforming Data Types with Casting 26

Operators 27

Order of Operations 30

Ordering Operations with Parentheses 30

Compound Assignment Operators 31

What You Learned 33

3 Making Choices 35

Boolean Expressions 36

Is Equal and Is Not Equal 36

Greater Than and Less Than 37

Compound Boolean Expressions 38

Conditional Statements 40

If Statements 40

Switch Statements 44

What You Learned 45

4 Writing Code that Loops 47

Open the Debug Area 48

Looping Through Ranges and Collections with for-in 48

Say Hello! 48

Say Good Morning! 50

Testing Conditions with while Loops 50

Guess My Number 51

Shrink Away 52

Which Loop to Use? 53

Nesting and Scope 54

Nesting Blocks of Code 54

Constant and Variable Scope 55

What You Learned 57

5 Keeping Your Programs Safe with Optionals 59

What Is an Optional? 60

Creating Optionals 60

Unwrapping Optionals 61

A Special Kind of Operator: ?? 65

What You Learned 65

6 Storing Collections in Dictionaries and Arrays 67

Keeping Things in Order with Arrays 67

Using Mutable and Immutable Arrays 68

Using Type Inference 69

Accessing Items in an Array 69

Watching the Range 69

Adding Items to an Array 70

Combining Arrays 71

Removing Items from an Array 71

Replacing Items in an Array 72

Using Array Properties 73

Looping Over an Array 74

Dictionaries Are Key! 75

Initializing a Dictionary 75

Accessing Values in a Dictionary 76

Adding Items to a Dictionary 77

Removing Items from a Dictionary 77

Replacing Items in a Dictionary 77

Using Dictionary Properties 78

Looping Over a Dictionary 78

What You Learned 79

7 Functions are a Party, and You're Invited 81

In with the Input, Out with the Output 81

Writing a Custom Function 82

Functions Do Even More with Input Parameters 84

Making Party Invitations 84

Inviting All Your Friends at Once 86

Messaging Your Guests 87

Argument Labels 89

Adding a Custom Argument Label 90

Removing an Argument Label 90

Return Values 91

Which Is the Bigger Box? 91

Conditional Returns 92

What You Learned 93

8 Custom Classes and Structs 95

Making a Class 96

Writing a Class Definition 96

Storing Information in Properties 97

Creating an Instance of a Class 98

Accessing the Properties of a Class 98

Customizing Each Cake with Initializers 100

Adding a Birthday Greeting Method 103

Writing a Helper Method 104

A Special Property Called self 106

Class Inheritance 108

Creating a Superclass 108

Creating a Subclass 109

Detecting the Data Type by Typecasting 110

Refining the Data Type by Downcasting 113

Value Types and Reference Types 114

Using Structs 117

What You Learned 118

Part 2 Birthday Tracker

9 Creating Buttons and Screens on the Storyboard 121

An Outline of Your App 122

Creating a New Xcode Project 122

Adding the App Icon 125

Displaying Your Friends' Birthdays 126

Adding the Table View Controller 127

Adding the Navigation Controller 129

Adding a Button 130

Setting Up Control Inputs and Labels 133

Adding Your Friends' Names and Birthdays 133

Making Your App Look Perfect on Every Device with Auto Layout 138

Adding Save and Cancel Buttons 139

What You Learned 140

10 Adding a Birthday Class and Handling User Input 141

The Birthday Class 142

Creating a New File 142

Writing the Birthday Class 144

Programming User Input 144

Creating the Add Birthday View Controller 145

Connecting Code to the Input Controls 146

Connecting Your Code to the Storyboard 147

Setting a Maximum Birthdate 149

Saving a Birthday 150

Hooking Up the Save Button 150

Reading Text from a Text Field 151

Getting a Date from a Date Picker 152

Creating a Birthday 153

Adding the Cancel Button 153

What You Learned 154

11 Displaying Birthdays 155

Making the Birthday List 155

Creating the Birthdays Table View Controller 156

Adding Cells to the Table View 158

Setting Up the Birthdays Table View Controller 161

Displaying Birthdays in a Table View 162

Putting It All Together 166

Delegation 166

Connecting the Two Controllers by Setting a Delegate 171

What You Learned 172

12 Saving Birthdays 173

Storing Birthdays in a Database 173

The Birthday Entity 174

The Birthday Attributes 175

The Application Delegate 177

Code Cleanup 182

Adding More Features to Our App 185

Alphabetizing Birthdays 185

Removing Birthdays 186

What You Learned 189

13 Getting Birthday Notifications 191

The User Notifications Framework 191

Registering for Local Notifications 192

Scheduling a Notification 194

Removing a Notification 199

What You Learned 200

Part 3 Schoolhouse Skateboarder

14 Setting the Stage 203

Where Do I Get Art and Sound Effects? 204

Making Games with Xcode's SpriteKit 204

Creating the Game Project 205

Adding Images 206

The Scenery: Displaying a Background Image 207

How It Will Be Played: Screen Orientation 211

Sizing Images for Different Screen Resolutions 213

What You Learned 216

15 Making Schoolhouse Skateboarder a Real Game 217

Our Hero, the Skateboarder 217

Creating a Skater Sprite Class 218

Importing SpriteKit 218

Adding Custom Properties to the Skater Class 218

Creating an Instance of the Skater in the Scene 219

Setting Up the Skater 220

Seeing the Skater on the Screen 222

Understanding SpriteKit's Debugging Information 223

Hittin' the Bricks 224

Creating Sidewalk Bricks 224

Updating Sidewalk Bricks 226

Filling the Screen with Bricks 228

Leaving Gaps to Jump 229

The Game Loop 231

Tracking the Update Time 231

Calculating Elapsed Time for Each Update 231

Adjusting Scroll Speed Using the Elapsed Time 232

Updating the Bricks 233

Up, Up, and Away-Making the Skater Jump 234

Using a Tap Gesture Recognizer 234

Simulating Gravity in a Simple Way 235

Checking for Landings 237

What You Learned 238

16 Using the Spritekit Physics Engine 239

Setting Up the Physics World 240

Physics Bodies 241

Giving Shape to the Physics Bodies 241

Setting Properties of Physics Bodies 242

Giving the skater Sprite a Physics Body 244

Adding Physics Bodies to Bricks 245

Contacts and Collisions 246

Handling Contacts and Collisions 246

Responding to Contacts 249

Applying Forces to Physics Bodies 250

Starting and Ending the Game 251

Starting the Game 251

Ending the Game 254

What You Learned 255

17 Adjusting Difficulty, Collecting Gems, and Keeping Score 257

Speeding Things Up 257

Adding Multilevel Platforms 258

Defining Multiple Brick Levels 259

Changing How Bricks Spawn 260

Adding Gems to Collect 262

Spawning and Tracking the Gems 262

Deciding When to Spawn a Gem 264

Removing Gems 264

Updating Gems 265

Collecting Gems 267

Adding Scoring and Labels 268

Creating Labels 268

Tracking the Score 272

Updating Labels 273

Updating the Player's Score 274

Making the Gems Valuable 275

Tracking the High Score 276

Tweaking the Gameplay 277

What You Learned 278

18 Game State, Menus, Sounds, and Special Effects 279

Tracking Game State 280

Adding a Menu System 282

Creating the MenuLayer Class 282

Displaying the Menu Layers When Needed 286

Removing the Menu Layer 288

Making Sounds 289

Adding the Sound Files 289

Playing the Sounds at the Right Time 290

Shooting Sparks 291

What You Learned 297

Resources 299

Troubleshooting Errors 300

Apple Documentation 300

Xcode Keyboard Shortcuts 301

iOS Simulator Keyboard Shortcuts 302

Xcode Versions 303

Index 305

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews