Coding iPhone Apps for Kids, 1st Edition

Book description

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 system
Why 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.

Publisher resources

View/Submit Errata

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. About the Author
  5. About the Technical Reviewer
  6. About the Illustrator
  7. Brief Contents
  8. Contents in Detail
  9. ACKNOWLEDGMENTS
  10. INTRODUCTION
    1. Who Should Read This Book?
    2. What’s in This Book?
    3. The Companion Website
    4. Have Fun!
  11. PART 1: XCODE AND SWIFT
    1. Chapter 1: HELLO, WORLD!
      1. Installing Xcode, Your Code Editor
      2. Your First App!
        1. Introducing the Storyboard
        2. Adding User Interface Elements with the Object Library
        3. Saving Your Work
      3. Running the App on a Real Device
      4. What You Learned
    2. Chapter 2: LEARNING TO CODE IN A PLAYGROUND
      1. Constants and Variables
        1. When to Use Constants vs. Variables
        2. Naming Constants and Variables
      2. Data Types
        1. Declaring Data Types
        2. Common Data Types
        3. Type Inference
        4. Transforming Data Types with Casting
      3. Operators
        1. Order of Operations
        2. Ordering Operations with Parentheses
        3. Compound Assignment Operators
      4. What You Learned
    3. Chapter 3: MAKING CHOICES
      1. Boolean Expressions
        1. Is Equal and Is Not Equal
        2. Greater Than and Less Than
        3. Compound Boolean Expressions
      2. Conditional Statements
        1. if Statements
        2. switch Statements
      3. What You Learned
    4. Chapter 4: WRITING CODE THAT LOOPS
      1. Open the Debug Area
      2. Looping Through Ranges and Collections with for-in
        1. Say Hello!
        2. Say Good Morning!
      3. Testing Conditions with while Loops
        1. Guess My Number
        2. Shrink Away
      4. Which Loop to Use?
      5. Nesting and Scope
        1. Nesting Blocks of Code
        2. Constant and Variable Scope
      6. What You Learned
    5. Chapter 5: KEEPING YOUR PROGRAMS SAFE WITH OPTIONALS
      1. What Is an Optional?
      2. Creating Optionals
        1. Unwrapping Optionals
        2. A Special Kind of Operator: ??
      3. What You Learned
    6. Chapter 6: STORING COLLECTIONS IN DICTIONARIES AND ARRAYS
      1. Keeping Things in Order with Arrays
        1. Using Mutable and Immutable Arrays
        2. Using Type Inference
        3. Accessing Items in an Array
        4. Watching the Range
        5. Adding Items to an Array
        6. Combining Arrays
        7. Removing Items from an Array
        8. Replacing Items in an Array
        9. Using Array Properties
        10. Looping Over an Array
      2. Dictionaries Are Key!
        1. Initializing a Dictionary
        2. Accessing Values in a Dictionary
        3. Adding Items to a Dictionary
        4. Removing Items from a Dictionary
        5. Replacing Items in a Dictionary
        6. Using Dictionary Properties
        7. Looping Over a Dictionary
      3. What You Learned
    7. Chapter 7: FUNCTIONS ARE A PARTY, AND YOU’RE INVITED
      1. In with the Input, Out with the Output
      2. Writing a Custom Function
      3. Functions Do Even More with Input Parameters
        1. Making Party Invitations
        2. Inviting All Your Friends at Once
        3. Messaging Your Guests
      4. Argument Labels
        1. Adding a Custom Argument Label
        2. Removing an Argument Label
      5. Return Values
        1. Which Is the Bigger Box?
        2. Conditional Returns
      6. What You Learned
    8. Chapter 8: CUSTOM CLASSES AND STRUCTS
      1. Making a Class
        1. Writing a Class Definition
        2. Storing Information in Properties
        3. Creating an Instance of a Class
        4. Accessing the Properties of a Class
        5. Customizing Each Cake with Initializers
        6. Adding a Birthday Greeting Method
        7. Writing a Helper Method
      2. A Special Property Called self
      3. Class Inheritance
        1. Creating a Superclass
        2. Creating a Subclass
        3. Detecting the Data Type by Typecasting
        4. Refining the Data Type by Downcasting
      4. Value Types and Reference Types
      5. Using Structs
      6. What You Learned
  12. PART 2: BIRTHDAY TRACKER
    1. Chapter 9: CREATING BUTTONS AND SCREENS ON THE STORYBOARD
      1. An Outline of Your App
      2. Creating a New Xcode Project
      3. Adding the App Icon
      4. Displaying Your Friends’ Birthdays
        1. Adding the Table View Controller
        2. Adding the Navigation Controller
        3. Adding a Button
      5. Setting Up Control Inputs and Labels
        1. Adding Your Friends’ Names and Birthdays
        2. Making Your App Look Perfect on Every Device with Auto Layout
        3. Adding Save and Cancel Buttons
      6. What You Learned
    2. Chapter 10: ADDING A BIRTHDAY CLASS AND HANDLING USER INPUT
      1. The Birthday Class
        1. Creating a New File
        2. Writing the Birthday Class
      2. Programming User Input
        1. Creating the Add Birthday View Controller
        2. Connecting Code to the Input Controls
        3. Connecting Your Code to the Storyboard
        4. Setting a Maximum Birthdate
      3. Saving a Birthday
        1. Hooking Up the Save Button
        2. Reading Text from a Text Field
        3. Getting a Date from a Date Picker
        4. Creating a Birthday
      4. Adding the Cancel Button
      5. What You Learned
    3. Chapter 11: DISPLAYING BIRTHDAYS
      1. Making the Birthday List
        1. Creating the Birthdays Table View Controller
        2. Adding Cells to the Table View
        3. Setting Up the Birthdays Table View Controller
        4. Displaying Birthdays in a Table View
      2. Putting It All Together
        1. Delegation
        2. Connecting the Two Controllers by Setting a Delegate
      3. What You Learned
    4. Chapter 12: SAVING BIRTHDAYS
      1. Storing Birthdays in a Database
        1. The Birthday Entity
        2. The Birthday Attributes
        3. The Application Delegate
      2. Code Cleanup
      3. Adding More Features to Our App
        1. Alphabetizing Birthdays
        2. Removing Birthdays
      4. What You Learned
    5. Chapter 13: GETTING BIRTHDAY NOTIFICATIONS
      1. The User Notifications Framework
        1. Registering for Local Notifications
        2. Scheduling a Notification
        3. Removing a Notification
      2. What You Learned
  13. PART 3: SCHOOLHOUSE SKATEBOARDER
    1. Chapter 14: SETTING THE STAGE
      1. Where Do I Get Art and Sound Effects?
      2. Making Games with Xcode’s SpriteKit
      3. Creating the Game Project
      4. Adding Images
      5. The Scenery: Displaying a Background Image
      6. How It Will Be Played: Screen Orientation
      7. Sizing Images for Different Screen Resolutions
      8. What You Learned
    2. Chapter 15: MAKING SCHOOLHOUSE SKATEBOARDER A REAL GAME
      1. Our Hero, the Skateboarder
        1. Creating a Skater Sprite Class
        2. Importing SpriteKit
        3. Adding Custom Properties to the Skater Class
        4. Creating an Instance of the Skater in the Scene
        5. Setting Up the Skater
        6. Seeing the Skater on the Screen
        7. Understanding SpriteKit’s Debugging Information
      2. Hittin’ the Bricks
        1. Creating Sidewalk Bricks
        2. Updating Sidewalk Bricks
        3. Filling the Screen with Bricks
        4. Leaving Gaps to Jump
      3. The Game Loop
        1. Tracking the Update Time
        2. Calculating Elapsed Time for Each Update
        3. Adjusting Scroll Speed Using the Elapsed Time
        4. Updating the Bricks
      4. Up, Up, and Away—Making the Skater Jump
        1. Using a Tap Gesture Recognizer
        2. Simulating Gravity in a Simple Way
        3. Checking for Landings
      5. What You Learned
    3. Chapter 16: USING THE SPRITEKIT PHYSICS ENGINE
      1. Setting Up the Physics World
      2. Physics Bodies
        1. Giving Shape to the Physics Bodies
        2. Setting Properties of Physics Bodies
        3. Giving the skater Sprite a Physics Body
        4. Adding Physics Bodies to Bricks
      3. Contacts and Collisions
        1. Handling Contacts and Collisions
        2. Responding to Contacts
      4. Applying Forces to Physics Bodies
      5. Starting and Ending the Game
        1. Starting the Game
        2. Ending the Game
      6. What You Learned
    4. Chapter 17: ADJUSTING DIFFICULTY, COLLECTING GEMS, AND KEEPING SCORE
      1. Speeding Things Up
      2. Adding Multilevel Platforms
        1. Defining Multiple Brick Levels
        2. Changing How Bricks Spawn
      3. Adding Gems to Collect
        1. Spawning and Tracking the Gems
        2. Deciding When to Spawn a Gem
        3. Removing Gems
        4. Updating Gems
        5. Collecting Gems
      4. Adding Scoring and Labels
        1. Creating Labels
        2. Tracking the Score
        3. Updating Labels
        4. Updating the Player’s Score
        5. Making the Gems Valuable
        6. Tracking the High Score
      5. Tweaking the Gameplay
      6. What You Learned
    5. Chapter 18: GAME STATE, MENUS, SOUNDS, AND SPECIAL EFFECTS
      1. Tracking Game State
      2. Adding a Menu System
        1. Creating the MenuLayer Class
        2. Displaying the Menu Layers When Needed
        3. Removing the Menu Layer
      3. Making Sounds
        1. Adding the Sound Files
        2. Playing the Sounds at the Right Time
      4. Shooting Sparks
      5. What You Learned
  14. RESOURCES
    1. Troubleshooting Errors
    2. Apple Documentation
    3. Xcode Keyboard Shortcuts
    4. iOS Simulator Keyboard Shortcuts
    5. Xcode Versions
  15. INDEX
  16. MORE SMART BOOKS FOR CURIOUS KIDS!

Product information

  • Title: Coding iPhone Apps for Kids, 1st Edition
  • Author(s): Gloria Winquist, Matt McCarthy
  • Release date: May 2017
  • Publisher(s): No Starch Press
  • ISBN: 9781593277567