Skip to main content
main-content
Top

About this book

Create your very own apps for the latest iOS devices. You'll start with the basics, and then work your way through the process of downloading and installing Xcode and the iOS 10 SDK, and then guides you though the creation of your first simple application.

Assuming little or no working knowledge of the Swift programming language, and written in a friendly, easy-to-follow style, Beginning iPhone Development with Swift 3 offers a comprehensive course in iPhone and iPad programming. In this third edition of the best-selling book, you’ll learn how to integrate all the interface elements iOS users have come to know and love, such as buttons, switches, pickers, toolbars, and sliders.

Every single sample app in the book has been rebuilt from scratch using the latest Xcode and the latest iOS 10-specific project templates, and designed to take advantage of the latest Xcode features. Discover brand-new technologies, as well as significant updates to existing tools. You’ll master a variety of design patterns, from the simplest single view to complex hierarchical drill-downs. The art of table building will be demystified, and you’ll learn how to save your data using the iOS file system. You’ll also learn how to save and retrieve your data using a variety of persistence techniques, including Core Data and SQLite. And there’s much more!

What You Will Learn

Develop your own bestselling iPhone and iPad appsUtilize Swift playgroundsDisplay data in Table Views

Draw to the screen using Core GraphicsUse iOS sensor capabilities to map your worldGet your app to work with iCloud and more

Who This Book is For

Anyone who wants to start developing for iPhone and iPad.

Table of Contents

Chapter 2. Writing Our First App

Abstract
I want to get you started right away with a feel for what this is all about and to motivate your continued progress toward being a great developer, so let’s get to it and do something with our iPhone (see Figure 2-1).
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche

Chapter 4. Adding Intermediate Level User Interactions

Abstract
In Chapter 3, we discussed MVC and built an application using it. You learned about outlets and actions, and you used them to tie a button control to a text label.
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche

Chapter 6. Creating a Multiview Application

Abstract
Up until this point, we’ve written applications using a single view controller. While single view apps can often do what you need them to, the real power of the iOS platform emerges when you switch out views based on user input. Multiview applications come in several different flavors, but the underlying mechanism functions the same, regardless of how the app appears on the screen. In this chapter, we’ll focus on the structure of multiview applications and the basics of swapping content views by building our own multiview app from scratch. Writing our own custom controller class that switches between two different content views, we’ll establishing a strong foundation for taking advantage of the various multiview controllers provided by Apple.
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche

Chapter 9. Adding Navigation Controllers to Table Views

Abstract
In the previous chapter, we worked through the basics of using table views. In this chapter, we’ll go further by adding navigation controllers.
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche

Chapter 11. Split Views and Popoversfor iPad Apps

Abstract
In Chapter 9, we spent a lot of time dealing with app navigation based on selections in table views, where each selection causes the top-level view, which filled the entire screen, to slide left and bring in the next view in the hierarchy. Many iPhone and iPod touch apps work this way such as Mail, which lets you drill down through mail accounts and folders until you make your way to the message. Although, this approach works on the iPad, it leads to a user interaction problem.
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche

Chapter 13. Persistence: Saving Data Between App Launches

Abstract
So far, we’ve focused on the controller and view aspects of the MVC paradigm. Although several of our applications read data from their own application bundle, only the Bridge Control example in Chapter 12 places any data in persistent storage. When any of our other apps launched, they appeared with exactly the same data they had when first launched. That approach worked up to this point, but in the real world, your apps need to persist data. When users make changes, they want to see those changes when they launch the program again.
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche

Chapter 16. Graphics and Drawing

Abstract
We’ve constructed all our application UIs so far using views and controls that are part of the UIKit framework. We can do a lot with UIKit, and a great many applications are constructed using only its predefined objects. Some visual elements (see Figure 16-1), however, can’t be fully realized without going beyond what the UIKit stock components offer.
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche

Chapter 18. Taps, Touches, and Gestures

Abstract
The screens of the iPhone, iPod touch, and iPad—with their crisp, bright, touch-sensitive display—represent masterpieces of engineering. The multitouch screen common to all iOS devices provides one of the key factors in the platform’s tremendous usability. Because the screen can detect multiple touches at the same time and track them independently, applications are able to detect a wide range of gestures, giving the user power that goes beyond the interface.
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche

Chapter 20. Device Orientation and Motion

Abstract
The iPhone, iPad, and iPod touch all include a built-in accelerometer—the tiny device that lets iOS know how the device is being held and if it’s being moved. iOS uses the accelerometer to handle autorotation, and many games use it as a control mechanism. The accelerometer can also be used to detect shakes and other sudden movement. This capability was extended even further with the introduction of the iPhone 4, which was the first iPhone to include a built-in gyroscope to let developers determine the angle at which the device is positioned around each axis. The gyro and accelerometer are now standard on all new iPads and iPod touches. In this chapter, we’ll explore using the Core Motion framework to access the gyro and accelerometer values in your application.
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche

Appendix A. An Introduction to Swift

Abstract
Until recently, writing an iPhone or iPad application meant working with Objective-C. Because of its unusual syntax, Objective-C is one of the most polarizing of programming languages—people tend to love it or hate it. At the World Wide Developer Conference in 2014, Apple changed all that by unveiling an alternative—a new language called Swift. Swift’s syntax is designed to be easily recognizable to programmers who are used to some of the more popular object-oriented programming languages like C++ and Java, therefore making it easier for them to start writing applications for iOS (and for Macs, since Swift is also fully supported as a development language on macOS). This appendix covers the parts of Swift that you’ll need to know in order to understand the example code in this book. We assume that you already have some programming experience and that you know what variables, functions, methods, and classes are. This appendix is neither a reference nor an exhaustive guide to the language—for that, there are numerous other resources, some of which are listed in Chapter 1.
Molly Maskrey, Kim Topley, David Mark, Fredrik Olsson, Jeff Lamarche
Additional information