Book Image

Swift Cookbook

By : Cecil Costa, Cecil Costa
Book Image

Swift Cookbook

By: Cecil Costa, Cecil Costa

Overview of this book

Table of Contents (18 chapters)
Swift Cookbook
About the Author
About the Reviewers

Upgrading the app delegate

As you know, there is an object that controls the events of an application called application delegate. Usually, you shouldn't have much code here, but you might have a few of them. For example, you may deactivate the camera or the GPS requests when your application goes to the background, and reactivate them when the app returns active.

Certainly, it's a good idea to update this file even if it doesn't have any new code in it. This will avoid any issues cropping up in the future.

Getting ready

If you are using the version control system, commit your changes from the last recipe or if you prefer, just copy your application.

How to do it...

To upgrade the app delegate, follow these steps:

  1. Open the previous application recipe, and create a new Swift file called ApplicationDelegate.swift, then you can create a class with the same name.

  2. As in our previous class, we didn't have any code for the application delegate, so we can differentiate it by printing on the log console...