Coding iPhone Apps for Kids: A Playful Introduction to Swift
Finally we are so grateful to Gloria’s dad Floyd Winquist for his patient and careful review of the book He tested all the examples read through several versions of all of the chapters and provided much valuable feedback xviii Acknowledgments
InTrodUCTIon Have you ever heard someone say I wish there was an app for that Maybe they were talking about a holiday card organizer or an app that can turn someone into a kitten Well you can be the person who makes that app In this book you’ll learn how to program in Swift the language used for mobile applications that run on all Apple devices By the time you’ve finished read ing you’ll have developed apps you can run on your iPhone iPad or iPod touch If you’re new to programming Swift is a great first programming lan guage It’s modern and powerful yet fun and easy to learn You can write Swift in Xcode’s playground which lets you see the results of your code immediately Once you have the basics down you can go from using the playground to creating mobile apps in Xcode that you can carry every where right in your pocket
Learning a programming language will give you skills in problem solv ing communication and creativity For these reasons and many more programming is a highly useful skill to have Even if you don’t intend to become a professional programmer if you regularly use a computer or a mobile device then learning to program can improve your life Who Should read This Book If you’re interested in learning how to program this book is a great place to start Coding iPhone Apps for Kids is targeted toward kids but it is also a good resource for adults who are new to programming You should find this book useful whether you have no programming experience or are an expe rienced programmer who wants to learn how to develop apps If you’re new to programming we recommend that you start at the beginning and then work your way forward chapter by chapter through Part 1 Xcode and Swift These chapters teach you basic programming skills that will build upon each other As you read test out the examples and try writing your own code If you have some experience programming in another language we recommend starting with Chapter 1 which shows you how to download and install Xcode and then walks you through creating a simple Hello world app You may feel comfortable skimming through Chapters 2 to 4 and 6 to 8 but don’t skip Chapter 5 It covers optionals which are an important programming feature that is unique to Swift What’s in This Book Chapter 1 covers installing Xcode on your computer and includes a simple tutorial to make a Hello world app that you can run on your iPhone iPad or iPod touch Chapter 2 delves into programming in an Xcode playground environ ment and shows you how to create variables and constants of different data types Chapters 3 and 4 teach you how to control the flow of a computer program Chapter 3 covers if statements and conditionals and Chapter 4 covers for-in and while loops Chapter 5 covers optionals which are variables or constants that can either have a value or no value Optionals are an important concept that’s unique to the Swift programming language so be sure to read this chapter carefully In Chapter 6 you’ll learn how to work with two Swift collection types arrays and dictionaries Chapter 7 covers writing functions which are blocks of code that can be called repeatedly to perform specific tasks In Chapter 8 you’ll learn how to make a custom class which is a blue print for creating objects that represent real-world items such as a back pack a car a cat or anything else that you can imagine xx Introduction
Part 2 Birthday Tracker includes Chapters 9 to 13 These five chapters walk you through creating an app that lets you save your friends birthdays on your phone and sends you reminders to wish them a happy birthday Part 3 Schoolhouse Skateboarder includes Chapters 14 to 18 These chapters walk you through the development of a game in which the player controls a skateboarder that jumps over cracks in the sidewalk and collects gems to increase their score Finally the Resources provide information that will help you as you make your own apps including tips for troubleshooting errors where to find useful documentation handy keyboard shortcuts and information about Xcode versions The Companion Website Swift is an evolving language and it gets updated often We’ll keep track of those updates and how they affect this book on the book’s website https www nostarch com iphoneappsforkids There you can also find all the down loads for the examples we use have fun Programming is fun for so many reasons you get to solve puzzles impress people with your code creations and feel pretty powerful once you know how to control a device So above all don’t forget to have fun Introduction xxi