Book Image

Swift iOS Programming for Kids

By : Steffen D. Sommer, Jim Campagno
Book Image

Swift iOS Programming for Kids

By: Steffen D. Sommer, Jim Campagno

Overview of 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.
Table of Contents (21 chapters)
Swift iOS Programming for Kids
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
2
Getting Set Up

Our first class


Go ahead and create a new Xcode playground and delete the autogenerated content. Let's continue with our example of modeling a person by adding the following to our playground:

class Person {
 
}

Note

All related source code for this chapter can be found here: https://github.com/swift-book-projects/swift-3-programming-for-kids/tree/master/Chapter-9

Let's take a look at the simple code we just wrote. The class keyword is how we define a class in Swift. Remember that a class is our abstract representation of something we are trying to model and the object is the instance of our class. Next, Person is the name of our class, and is also called our type. In Swift, we capitalize the names of our classes. This is similar to other types we have seen so far, such as String and Int; the difference being that this is a type that we define ourselves.

If we want to instantiate our new class that does not hold any functionality, we will do it by writing the following code:

let bob = Person...