For the More Curious: Application State Transitions

Let’s write some quick code to get a better understanding of the different application state transitions.

In AppDelegate.swift, implement the application state transition delegate methods so that they print out the name of the method. You will need to add four more methods. (Check to make sure the template has not already created these methods before writing brand new ones.) Rather than hardcoding the name of the method in the call to print(), use the #function expression. At compile time, the #function expression will evaluate to a String representing the name of the method.

func applicationWillResignActive(_ application: UIApplication) {
    print(#function)
} func applicationDidEnterBackground(_ ...

Get iOS Programming: The Big Nerd Ranch Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.