This book is an excellent introduction to iOS programming using Swift, especially for young coders looking to get started with app development.
Swift is a new language that's great for creating iOS Apps. With this book, you'll use Swift to develop your own iOS Apps and even upload them to the App store. You'll also learn fundamental programming skills along the way.
Hello Swift! is a how-to guide to programming iOS Apps with the Swift language, written from a kid's perspective. This approachable, well-illustrated, step-by-step guide takes you from very beginning programming concepts through developing complete apps. You'll begin by learning the basics of what an App is and what you need to build one. From there, you'll create your first simple App before learning more about programming with Swift. Along the way, you'll conquer important programming concepts that you can use with other programming languages. By the end of this book you'll have everything you need to dive into the world of iOS App Development.
1 Get ready to build apps with Swift!
1.1 Your “I can do it!” journey begins
1.1.1 What is an app, anyway?
1.1.2 The pieces of a good app
1.1.3 What is programming?
1.1.4 From idea to app
1.2 What is Swift?
1.2.1 What’s so special about Swift?
1.2.2 Swift can’t do everything
1.3 Time to prep your App Toolbox!
1.3.1 Gather hardware
1.3.2 Install Xcode
1.3.3 Setup Optional Developer Account
1.3.4 Start XCode for the first time
1.4 Write code and see it work in the Swift Playground
1.4.1 What Is the Playground?
1.4.2 Create a Playground
1.4.3 Play with code in the Playground
1.5 Check your app knowledge!
2 Create Your First App
2.1 Hello Apps!
2.2 Your first app: Hello World!
2.2.1 What does this app do?
2.2.2 Set up the project
2.2.3 The Xcode interface
2.2.4 Create the UI
2.2.5 Run your app!
2.3 Discover the User Interface
2.3.1 What is a UI?
2.3.2 On your own…
2.3.3 Change text colors
2.3.4 Change the background color of a control
2.3.5 Change the background color of a view
2.3.6 More about controls: Try these for a challenge
2.3.7 A few more things you can do with the Attributes Inspector
2.3.8 Segues: Using controls to navigate through screens
2.4 Designing good user interfaces
2.5 Try this app on your own
2.6 Test your App-Knowledge
3 Your First Real Swift Code Using Variables!
3.1 Apps store data in variables
3.1.1 What is a variable?
3.1.2 Hands on!
3.1.3 How does an app use and save variables?
3.1.4 What types of variables are there?
3.1.5 How to create variables
3.1.6 Hands on!
3.2 Declaring variables and changing values
3.2.1 Declaring variables
3.2.2 Changing variable values
3.2.3 Hands on! Spying on data
3.2.4 Using \ and () to format text
3.3 Transforming your data
3.3.1 Concatenating data
3.3.2 Hands on!
3.3.3 Test these rules
3.3.4 Converting data
3.4 Math Operation Theater
3.4.1 What is an Operation?
3.4.2 Do basic Math with Swift (+, -, *, /)
3.4.3 So I can only do math in a print() function?
3.4.4 Step up in math with Swift (square root, power, modulus)
3.4.5 Hands on!
3.4.6 Advanced math in the playground
3.5 Check your App-Knowledge
4 I/O Laboratory
4.1 How apps and users interact
4.2 How do users get output?
4.2.1 Start with Hello World
4.2.2 Add a variable to hold the label
4.2.3 Connect your label variable to a label on the view
4.2.4 The Interface Builder
4.3 Users give Apps Input
4.3.1 Add a text field and button to the app
4.3.2 Add code to connect the text field to code
4.3.3 Add the function to change the label text to input text
4.4 Check Your App-Knowledge
4.5 APPTIVITY: Concatenate
4.5.1 What does this app do?
4.5.2 Create the UI
4.5.3 Code the app
4.6 APPSERCISE: Greeting Generator
4.6.1 What does this app do?
4.6.2 Create the UI
4.6.3 Code the app
4.6.4 Run the app
5 Computers make decisions, too!
5.1 Conditions with the if statement
5.1.1 if this is true, then do something
5.2 App: Which Number is Bigger?
5.2.1 What does this app do?
5.2.2 Set up the project
5.2.3 Create the UI
5.2.4 Code the app
5.2.5 Connect IBOutlets to Controls and IBActions to Buttons
5.2.6 Learn How the Code Works
5.2.7 Run the App
5.2.8 Run the app again!
5.2.9 Run the code, again!
5.2.10 Recapping the If, Else, and Else If statement
5.3 Switch statements
5.4 App: The Mystery of the Entered Number
5.4.1 What does this App do?
5.4.2 Create the UI
5.4.3 Code the App
5.4.4 Run the App
5.5 Check Your App-Knowledge
5.6 APPSERCISE: Gold, Silver, Bronze
5.6.1 What does this app do?
5.6.2 Set up the project
5.6.3 Create the UI
5.6.4 Code the app
5.6.5 Run your app!
5.7 APPSERCISE: Times Tables Bee
5.7.1 What does this app do?
5.7.2 Set up the project and create the UI
5.7.3 Code the app
5.7.4 Learn How the Code Works
5.7.5 Run Your App!
6 Let Computers Do Repetitive Work
6.1 Controlling Repetition
6.2 For-In loop statements
6.2.1 Try it Yourself
6.2.2 How does it work?
6.2.3 Playground Example
6.3 While loop statements
6.3.1 Try it yourself
6.3.2 The Not Equal To (!=) Operator
6.3.3 Playground example
6.3.4 The repeat while loop
6.3.5 Playground Exercise: Repeat While
6.4 APP: How Many Times?
6.4.1 What does this app do?
6.4.2 Set Up the Project and Create the UI
6.4.3 Code the App
6.4.4 Run Your App
6.5 Check Your App-Knowledge
6.6 APPSERCISE Hang your Word Upside-Down!
6.6.1 What does this app do?
6.6.2 Explanation, Playground Exercise and including the helper code
6.6.3 Set Up the Project and Create the UI
6.6.4 Code the App
6.6.5 Run your App!
7 Knitting Variables into Arrays and Dictionaries
7.1 Why do we need arrays and dictionaries?
7.2 What is an array?
7.2.1 IMPORTANT: Arrays start counting with 0!
7.2.2 Getting to your data
7.2.3 Altering the Array
7.2.4 Looping Through Arrays
7.3 APP: 10 Number Sorter
7.3.1 What does this app do?
7.3.2 Set up the project and create the UI
7.3.3 Code the App
7.3.4 Learn How the Code Works, including the SELECTION SORT algorithm!
7.3.5 Run your app!
7.4 Go to the second dimension: rows and columns!
7.5 What is a dictionary?
7.5.1 Turning a dictionary into code
7.5.2 Creating a dictionary and getting to your data
7.5.3 Changing the dictionary
7.5.4 Looping through data in dictionaries
7.6 APP: Friend List
7.6.1 What does this app do?
7.6.2 Set Up the App and Create the UI
7.6.3 Code the App
7.7 Check Your App Knowledge
7.8 APPSERCISE: Alphabet Unscrambler
7.8.1 What does this app do?
7.8.2 Set up the project and Create a UI
7.8.3 Code the App
7.8.4 Learn how the code works
7.8.5 Run the app!
8 Reuse your code — Clean it with Function Detergent!
8.1 Reuse and Clean your code with Functions
8.1.1 Simple Functions
8.2 Giving info to your reusable code!
8.2.1 Try it for yourself.
8.3 Getting Info from your Reusable Code!
8.3.1 Try it yourself
8.4 CHECK YOUR APP KNOWLEDGE
8.5 APPSERCISE: Virtual Dice: Never lose your dice again!
8.5.1 What does this app do?
8.5.2 Set up the project and creating the UI
8.5.3 Code the App
8.5.4 Learn how the code works
8.5.5 Run your app!
8.6 APPSERCISE: Rock Paper Scissors!
8.6.1 What does this app do?
8.6.2 Set up the project and create the UI
8.6.3 Code the app
8.6.4 Connect the IBOutlets and IBActions
8.6.5 Learn how the code works
8.6.6 Run your app!
8.7 APPSERCISE: Money Denomination
8.7.1 What does this app do?
8.7.2 How does this app work?
8.7.3 Set up the project and create the UI
8.7.4 Codethe App
8.7.5 ConnectIBOutlets and IBActions
8.7.6 Run the app!
9 Reduce Your Code — Use Less, Do More with Class Detergent
9.1 Reduce and Clean your code with Classes
9.1.1 What is a class?
9.1.2 Let’s have some fun with classes
9.1.3 How do classes reduce code?
9.2 Create a class
9.2.1 Add a variable
9.2.2 Create Instances of your class
9.2.3 Change the value of a variable
9.2.4 Adding Functionality to Classes
9.2.5 Quick review
9.2.6 Add an initializer that does something every time you create an instance
9.3 Like father, like son: Inheritance!
9.3.1 Let’s try it
9.4 Where can I exist? All about scope.
9.4.1 What is variable scope?
9.5 APP: Calculator!
9.5.1 What does this app do?
9.5.2 Create the UI
9.5.3 How does this app work?
9.5.4 Code the App
9.5.5 Connect IBOutlets and IBActions
9.5.6 Run the app
9.6 Check Your App Knowledge!
9.7 APPSERCISE: Metric Conversion!
9.7.1 What does this app do?
9.7.2 Math: Negative powers
9.7.3 Creating the UI
9.7.4 Code the app
9.7.5 Connect IBOutlets and IBActions
9.7.6 Run your app!
9.8 Appsercise: Metric Conversion Handler (Part 2!)
9.8.1 What does this app do?
9.8.2 Code the App
9.8.3 Run the app
10 Reading and Writing Files
10.1 What is in a file?
10.1.1 What is File Content Managing?
10.2 APP: File Content Manager
10.2.1 What does this app do?
10.2.2 Set up the project and create the UI
10.2.3 Code the App
10.2.4 Learn how the code works
10.2.5 Run your app
10.3 APP: Hangman
10.3.1 What does this app do?
10.3.2 Setup the project and create the UI
10.3.3 Code the app
10.3.4 Connect the Variables, IBOutlets, and IBActions
10.3.5 Run the app
10.4 Check your App-Knowledge
10.5 APPTIVITY: Store your name and birth date
11 Frameworks — Bookshelves of Classes
11.1 What is a framework?
11.2 Let’s Create a framework
11.2.1 What does this app do?
11.2.2 Create the project — this one’s different!
11.2.3 Code the app
11.2.4 Learn how the code works
11.2.5 Build the framework
11.2.6 Use the framework
11.3 APP: Read and write (Part 2!), using frameworks!
11.3.1 What will we do to this app?
11.3.2 Removing the “read” and “write” functions
11.3.3 Creating the framework reference in Xcode
11.3.4 Coding the framework into the “LoadSave” app
11.3.5 Run your app!
11.4 Check Your App-Knowledge
12 SpriteKit -Fun Animation Time
12.1 Let’s meet SpriteKit
12.2 How does SpriteKit work?
12.2.2 Coordinate System
12.3 APP: Drag the Square (DTS)!
12.3.1 What does this app do?
12.3.2 Create the project
12.3.3 Code the app
12.3.4 Run the app
12.4 A Christmas Tree app to try on your own
12.5 Check your app knowledge
13 Time to Watch Your WatchKit Code
13.1 APP: Number Guessing Game
13.1.1 What does this app do?
13.1.2 Create the UI
13.1.3 Coding the Application
13.1.4 Run your Application
13.2 Check your App Knowledge
14 Continuing your Journey with Swift
14.1.1 Author’s Forum
14.1.2 Stack Overflow
14.1.4 YouTube and Books
14.2 What’s next?
Appendix A: Check if I am Prime!
A.1 What does this app do?
A.2 Setup the project and Create the UI
A.3 Code the app
A.3.1 Create IBOutlets and IBActions
A.4 Run your app!
Appendix B: Mean Median Detective
B.1 What does this app do?
B.2 Setup the project and create the UI
B.3 Code the app
B.4 Create the IBOutlets, functions, and IBActions
B.5 Extra challenge
Appendix C: Factoring Factory
C.1 What does this app do?
C.2 Setup the project and create the UI
C.3 Code the app
C.3.1 Create IBOutlets and IBActions
Appendix D: How Big Is a Triangle?
D.1 What does this app do?
D.2 Setup the project and create the UI
D.3 Code the app
D.3.1 Add the IBOutlets and IBAction
D.3.2 Learn how the code works
Appendix E: I am mixed up, make me improper!
E.1 What does this app do?
E.2 Set up the project and create the UI
E.3 Learn how this code works
E.4 Code the app
E.4.1 Create the IBOutlets, functions, and IBActions
Appendix F: Installation
- Crystal-clear explanations
- Engaging images and and straightforward examples
- Hands-on lessons
- Exercises that encourage critical thinking
About the reader
While written with a younger audience in mind, this book is for readers of any age with no programming experience who want to enjoy learning to create iOS Apps.
About the author
Tanmay Bakshi began coding at the age of four and had his first App on the iOS App Store by the age of nine. He taught himself Swift when it was still in beta. He's excited about passing on his knowledge to other young and new programmers.
Lynn Beighley is the author of more than a dozen programming and technical books, including the bestsellers Head First SQL and Head First PHP & MySQL.
Very gentle and explicit introduction for absolute beginners.
Good introductory book, both for iOS and programming in general.