Skip to main content
main-content
Top

About this book

Stay motivated and overcome obstacles while learning to use Swift Playgrounds and Xcode 10.2 to become a great iOS developer. This book, fully updated for Swift 5, is perfect for those with no programming background, those with some programming experience but no object-oriented experience, or those that have a great idea for an app but haven’t programmed since school.

Many people have a difficult time believing they can learn to write iOS apps. Swift 5 for Absolute Beginners will show you how to do so. You'll learn Object-Oriented Programming (OOP) and be introduced to User Interface (UI) design following Apple’s Human Interface Guidelines (HIG) using storyboards and the Model-View-Controller (MVC) pattern before moving on to write your own iPhone and Apple Watch apps from scratch.

What You’ll Learn

Work with Swift classes, properties, and functions

Examine proper User Interface (UI) and User Experience (UX) design

Understand Swift data types: integers, floats, strings, and booleans

Use Swift data collections: arrays and dictionaries

Review Boolean logic, comparing data, and flow control

Use the Xcode debugger to troubleshoot problems with your apps

Store data in local app preferences and Core Data databases

Who This Book Is For

Anyone who wants to learn to develop apps for the Mac, iPhone, iPad, and Apple Watch using the Swift programming language. No previous programming experience is necessary.

Table of Contents

Chapter 1. Becoming a Great iOS Developer

Abstract
Now that you’re ready to become a software developer and have read the introduction of this book, you need to become familiar with several key concepts. Your computer program will do exactly what you tell it to do—no more and no less. It will follow the programming rules that were defined by the operating system and the Swift programming language. Your program doesn’t care if you are having a bad day or how many times you ask it to perform something. Often, what you think you’ve told your program to do and what it actually does are two different things.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 2. Programming Basics

Abstract
This chapter focuses on the building blocks that are necessary to become a great Swift programmer. This chapter covers how to use the playground user interface, how to write your first Swift program, and how to use the Xcode Integrated Development Environment (IDE).
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 3. It’s All About the Data

Abstract
As you probably know, data is stored as zeros and ones in your computer’s memory. However, zeros and ones are not very useful to developers or app users, so you need to know how your program uses data and how to work with the data that is stored.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 4. Making Decisions, Program Flow, and App Design

Abstract
One of the great things about being an iOS developer is you get to tell your devices exactly what you want them to do and they do it—your devices will do tasks over and over again without getting tired. That’s because iOS devices don’t care how hard they worked yesterday, and they don’t let feelings get in the way. These devices don’t need hugs.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 5. Object-Oriented Programming with Swift

Abstract
Over the past 17 years, the programming world focused on the development paradigm of object-oriented programming (OOP). Most modern development environments and languages implement OOP. Put simply, OOP forms the basis of everything you develop today.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 6. Learning Swift and Xcode

Abstract
For the most part, all programming languages perform the typical tasks any computer needs to do—store information, compare information, make decisions about that information, and perform some action based on those decisions. The Swift language makes these tasks easier to understand and accomplish. The real trick with Swift (actually, the trick with most programming languages) is to understand the symbols and keywords used to accomplish those tasks. This chapter continues the examination of Swift and Xcode so you can become even more familiar with them.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 7. Swift Classes, Objects, and Methods

Abstract
If you haven’t already read Chapter 6, please do so before reading this one because it provides a great introduction to some of the basics of Swift. This chapter builds on that foundation, especially with creating Swift classes. By the end of this chapter, you can expect to have a greater understanding of the Swift language and how to use the basics to write simple programs. The best way to learn is to take small programs and write (or rewrite) them in Swift just to see how the language works.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 8. Programming Basics in Swift

Abstract
Swift is an elegant language. It mixes the efficiency of a compiled language with the flexibility and modern features of many scripting languages.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 9. Comparing Data

Abstract
In this chapter, we will discuss one of the most basic and frequent operations you will perform as you program: comparing data. In the bookstore example, you may need to compare book titles if your clients are looking for a specific book. You may also need to compare authors if your clients are interested in purchasing books by a specific author. Comparing data is a common task performed by developers. Many of the loops you learned about in Chapter 8 will require you to compare data so that you know when your code should stop looping.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 10. Creating User Interfaces

Abstract
Interface Builder enables iOS developers to easily create their user interfaces using a powerful graphical user interface. It provides the ability to build user interfaces by simply dragging objects from Interface Builder’s library to the editor.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 11. Storing Information

Abstract
As a developer, there will be many different situations when you will need to store data. Users will expect your app to remember preferences and other information each time they launch it. Previous chapters discussed the BookStore app. With this app, users will expect your application to remember all of the books in the bookstore. Your application will need a way to store this information, retrieve it, and possibly search and sort this data. Working with data can sometimes be difficult. Fortunately, Apple has provided methods and frameworks to make this process easier.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 12. Protocols and Delegates

Abstract
Congratulations! You are acquiring the skills to become an iOS developer! However, iOS developers need to understand two additional topics in order to be successful: protocols and delegates. It is not uncommon for new developers to get overwhelmed by these topics, which is why we introduced the foundational topics of the Swift language first. After reading this chapter, you will see that protocols and delegates are really useful and not hard to understand and implement.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 13. Introducing the Xcode Debugger

Abstract
Not only is Xcode provided free of charge on Apple’s developer site and the Mac App Store, but it is also a great tool. Aside from being able to use it to create the next great Mac, iPhone, iPad, AppleTV, and Apple Watch apps, Xcode has a debugger built right into the tool.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 14. A Swift iPhone App

Abstract
In Chapter 8, you created a basic bookstore iPhone app with Swift. In this chapter, you will add some features to the app to make it a bit more functional and use many of the technologies you have learned in this book, such as creating a class, using delegates and protocols, and using actions and outlets. You will also learn about some new techniques such as switches, UIAlertController, and landmarks.
Stefan Kaczmarek, Brad Lees, Gary Bennett

Chapter 15. Apple Watch and WatchKit

Abstract
In September 2014, Apple announced the Apple Watch, which it considers to be the next chapter in Apple’s history. This watch not only handles phone calls and text messages, but it also assesses the wearer’s health by tracking heart rate and exercise. At the same time, Apple announced WatchKit, a framework designed for developing apps for the Apple Watch. WatchKit will be very familiar to developers already familiar with UIKit.
Stefan Kaczmarek, Brad Lees, Gary Bennett
Additional information