Swift iOS Programming for Kids

By Steffen D. Sommer , Jim Campagno
    What do you get with a Packt Subscription?

  • Instant access to this title and 7,500+ eBooks & Videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
About this book

This book starts at the beginning by introducing programming through easy to use examples with the Swift Playgrounds app. Kids are regularly encouraged to explore and play with new concepts to support knowledge acquisition and retention – these newly learned skills can then be used to express their own unique ideas. Children will be shown how to create their first iOS application and build their very own movie night application.

Publication date:
March 2017


Chapter 1.  What is Programming?

We use programming to instruct a computer. Computers include smartphones (such as the iPhone), tablets, game consoles (such as the PlayStation), and a lot more. We say that a computer runs a program, which means that when you open your favorite game or application (also referred to as an app) on your PlayStation or on your iPhone, the device will know how to interpret and execute the program, which in this case is your game or application. A program is simply a set of instructions that your device is able to understand. We can also consider these instructions as a recipe for the device. The recipe will tell your iPhone what your favorite game is all about-everything from the colors of your avatar, to the text in the menus, to what happens when you tap on an enemy or on an animal in a game. This recipe can be written in many ways depending on your personal preference and the device that is supposed to run it. The programming language refers to the language you choose to write your program in. 

This chapter will go through the following topics:

  • Introducing the Swift programming language

  • Why is programming important?

  • What the reader can expect from this book


The Swift programming language

Swift is a programming language introduced by Apple, which you can use to create apps for the most common Apple devices, including the iPhone. The language and device you choose defines the possibilities for your program, for example, using Swift and targeting an iPhone as your device, you will be able to access the camera of the iPhone to take photos in your application, or the speaker of the iPhone in order to play sounds in your application. If you choose JavaScript as your programming language, HTML as your markup language and target the browser on your computer as your device, then you will be able to create interactive web pages. A programming language can differ much from language to language, and although the languages can share common concepts, it does not mean that one will master every programming language just by learning one. This leads to what programming is: it is the act of creating a program or recipe for your device to run. What is the result? The result is your program, your application, or your game.

Let's imagine this simple application for an iPhone-Movie Night, which has a list of your favorite movies. If the list is longer than the height of your device, you are able to scroll through the list by swiping up and down. You can add movies to your list by tapping a button and entering a name for the movie and you can delete them again by swiping left on the movie in the list. The idea of the app is to keep a list of your favorite movies so that you can remember them when having a movie night. In this case, the program is the application (called Movie Night), the device is the iPhone, and the instructions of the application could be the colors of the background and texts, the list in which you can scroll, and the add and delete functionalities. Programming is about creating these set of instructions so that we are able run our application on our iPhone. If you're excited about creating your own Movie Night app that you can use with your friends, then read along as this is an application we will build together in Chapter 14, Movie Night - iOS App.


Why is programming important?

There are many reasons for why programming is becoming increasingly popular. The result of doing programming allows people to connect through social media, such as Facebook and Instagram; it allows people to be entertained through immersive and rich games; and it allows people to learn and become educated in a fun and engaging manner using interactive applications. Programming has enabled us to share knowledge across geographical boundaries in a way that seemed impossible before programming existed. Programming has helped us automate tasks such as selling tickets at the local train station, paying in a faster and secure way using our smartphone, and programming has helped us measure the well-being of humans in order to give the right treatment at the right moment.

Programming has made it possible for us to instruct a computer on how to perform certain tasks in a more efficient and reliable manner than would ever be possible for a human being. There are natural limits to how much a person can do within the 24 hours of a day or within the lifetime of a person's life. Also, it is costly to have a person perform tedious tasks that seem repetitive, time-consuming, or based on deterministic behavior, such as calculations. As it is costly and it can be hard to find the right or, simply, enough people, it also means that it does not scale very well. Computers are relatively cheap and can be considered as fairly stable. If computers break, they are easy to replace, which means that performing tasks using computers scales really well. Just imagine a bank system without computers; imagine people sitting and keeping track of each person's balance and trying to keep it synchronized across large geographical distances.

Imagine the recent Pokémon smartphone game being done without computers. With no computers, there would need to be maps distributed to each player that show exactly where a Pokémon is located and people (from the game) would need to be at the actual geographical location in order to tell or validate that the Pokémon trainer had just found a Pokémon. Also, in order to keep track of Pokémon caught, and not to mention the outcome of a battle with another trainer, a lot needs to be handled on paper by the player. Without computers, one can easily think of problems with consistent play experiences, such as verifying that a player does not cheat and modifying the game rules as the game evolves, just to name a few. In general, computers have the ability to enhance our daily life, and we quickly forget what the world would look like without computers. Traditionally, programming has had a steep learning curve and, in general, been inaccessible by younger people. Today, programming is widely used and we have many different languages and tools that solve a lot of different types of problems. This means that it has been possible to lower the learning curve and involve people of different ages and with different capabilities.


What you will learn from this book

This book gives you an introduction to the programming language, Swift. Swift is a fairly new programming language (version 1 came out in September 2014) and the language can be used to write programs for most of the Apple devices, including the iPhone, iPad, Apple Watch, MacBook, and Apple TV. Throughout the book, we will gradually introduce you to more and more programming concepts until we have enough knowledge to start creating our own programs. The book will let you create programs such as a small Pokémon game, where Pokémon will be able to battle each other.

We will also be creating an app to deliver pizzas in outer space and the aforementioned Movie Night app to keep a list of your favorite movies. After creating our programs, you will be able to install the applications on an iPhone and show it to your friends. After being introduced to Swift and the knowledge and tools required to create an application for the iPhone, you should be able to continue to explore this area of programming. You should not only be able to continue working on the applications we create throughout this book, but also be capable of continuing the learning journey using other books or Internet resources. By using the skills provided in this book along with some imagination, a lot of fun and useful applications can be created for iOS devices such as the iPhone.



In this chapter, we looked at what programming actually is, why it is useful, and examples of what we use programming for. We discussed what a world without programming would look like and we looked at a short introduction to the Swift programming language. Lastly, we introduced what the reader can expect to learn when reading this book and how this can be used moving further into the world of programming.

In the next chapter, we will go over the practical part of getting the user set up with the right tools in order to begin programming.

About the Authors
  • Steffen D. Sommer

    Since Swift was announced at WWDC, Steffen D. Sommer has had a passionate interest in the programming language. He's currently working as a lead Vapor developer at a company called Nodes in Copenhagen, where he focuses on developing backend systems using Swift.

    In his spare time, he helps organize the local iOS meet up, visits iOS conferences around the world, and explores the different aspects of and use cases for Swift, such as putting Swift on the server and doing functional programming in Swift. You can also find him contributing to open source projects on GitHub or blogging on his personal website.

    Browse publications by this author
  • Jim Campagno

    Jim Campagno is an iOS developer and teacher living in New York City. He's currently working as an iOS instructor at the Flatiron School, helping beginners of Swift and iOS become iOS developers.

    Jim has a deep desire and high level of creativity that he brings to teaching. He created the Swift online course offered at Flatiron School, which includes in-depth readings along with test-driven labs, challenging the student to write code in Swift. Jim also runs an active YouTube channel, putting out in-depth content and helping students understand everything in iOS and Swift—from the basics to complex topics.

    Most importantly, Jim ensures that the content he creates is accessible, fun, and interactive. He enjoys putting together a story behind every topic to make it more enjoyable for the reader.

    Browse publications by this author
Swift iOS Programming for Kids
Unlock this book and the full library FREE for 7 days
Start now